Why Android use separate xmlns for ContraintLayout

白昼怎懂夜的黑 提交于 2020-08-09 08:14:33

问题


I'm little confused about ConstraintLayout in Android. I was learning about it and first thing I get confused about it why android use separate xml namespace for it? xmlns:app="http://schemas.android.com/apk/res-auto"

ConstraintLayout is part of Layout then why google didn't added it in the old namespace? xmlns:android="http://schemas.android.com/apk/res/android"

and why android required to write full qualified name in XML? android.support.constraint.ConstraintLayout why not just ConstraintLayout? as RelativeLayout?


回答1:


ConstraintLayout is part of Layout then why google didn't added it in the old namespace?

That is reserved for platform-defined attributes. ConstraintLayout is from a library, not from the platform.

and why android required to write full qualified name in XML? android.support.constraint.ConstraintLayout why not just ConstraintLayout?

Android only knows to look in a couple of platform-defined packages for views using the shorthand, bare-class-name-only notation. android.support.constraint is from a library, not the platform.



来源:https://stackoverflow.com/questions/42958196/why-android-use-separate-xmlns-for-contraintlayout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!