Android XML元素和名称空间

Android XML元素和名称空间,android,xml,view,android-activity,Android,Xml,View,Android Activity,不能简化活动XML文件中自定义元素的名称吗 <com.library.CustomView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res/com.example.library.customview" android:id="@+id/myView" app:new

不能简化活动XML文件中自定义元素的名称吗

<com.library.CustomView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res/com.example.library.customview"
        android:id="@+id/myView"
        app:newAttr="value" />

例如,假设我有一个CustomView控件。我是否总是必须将“com.library.”放在“CustomView”前面,或者是否可以在FrameLayout中使用xmlns:custom,这样我就不需要了

这是我希望看到的(如果可能的话):


否。必须指定自定义视图类的完全限定名称。自定义属性属于不同的命名空间。所以你需要

 http://schemas.android.com/apk/res/[your package name].
这就是为什么你有

 xmlns:app="http://schemas.android.com/apk/res/com.example.library.customview"
有必要指定自定义视图的完全限定名称,从而

 <com.library.CustomView

感谢您的澄清。我将坚持使用完全限定的名称。我想这确实让事情变得更清楚了。。即使它不“整洁”:
 <com.library.CustomView