android-什么是XML属性xmlns:app?
作者:互联网
XML与以下各项配合良好:
xmlns:app="http://schemas.android.com/apk/res-auto"
但看不到最大字符
xmlns:app="http://schemas.android.com/tools"
由Android Studio auto完成.
这是我的XML:
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/remark_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
app:met_maxCharacters="20"
app:met_baseColor="@color/black"
app:met_primaryColor="@color/white" />
解决方法:
Xmlns代表“ XML命名空间”
>’:’之后的部分是命名空间的前缀
>“ =”之后的部分是命名空间URI(其部分的正确名称实际上是“命名空间名称”).
(有关更多详细信息,请参见https://en.wikipedia.org/wiki/XML_namespace)
命名空间“ schemas.android.com/tools”用于指定通过Android Studio构建应用的选项,但不包含在最终的应用包中
命名空间“ schemas.android.com/apk/res-auto”用于所有自定义属性-在库或代码中定义.有关详细信息,请参见this answer.
请注意,任何前缀都可以用于名称空间,对于schemas.android.com/apk/res-auto,并非必须使用“ app”.但是,在文档中定义自定义属性时必须使用相同的前缀,否则将显示错误.
因此,由于met_maxCharacters是自定义属性,因此在使用’schemas.android.com/apk/res-auto’名称空间时会显示该属性,而不是使用
‘schemas.android.com/tools’
标签:android,android-xml 来源: https://codeday.me/bug/20191010/1887356.html