Home
2018年4月29日 星期日

[程式] Android Studio : Tools屬性說明(Tools Attributes)

Tools用於開發階段,設計與編譯時期使用,當產生APK時,就會自動移除相關屬性,不會影響APK的大小或執行期的行為。
要使用tools相關屬性,需要在根目錄新增tools的namespace(命名空間)
xmlns:tools="http://schemas.android.com/tools"
細部項目請參考官方文件

相關資訊圖片:

Tools Attributes View1 (Without Tools Attributes)畫面
Tools Attributes View1 (Without Tools Attributes)畫面



Tools Attributes View2 (With Tools Attributes)畫面
Tools Attributes View2 (With Tools Attributes)畫面


初始畫面
初始畫面


Source Code:

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        tools:text="This is tools:text!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />


參考資料:

0 意見:

張貼留言