Android xmlns:tools 命名空间

by on under jekyll
1 minute read

tools可以告诉Android Studio,哪些属性在运行的时候是被忽略的,只在设计布局的时候有效。比如要让android:text属性只在布局预览中有效可以这样:

        <TextView
        android:id="@+id/text_main"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:text="I am a title" />

tools可以覆盖android的所有标准属性,将android:换成tools:即可。同时在运行的时候就连tools:本身都是被忽略的,不会被带进apk中。

Android