我对Android中的ConstraintLayout有点困惑。我正在学习它,第一件事让我感到困惑,为什么Android为此使用单独的xml名称空间? xmlns:app="http://schemas.android.com/apk/res-auto"

ConstraintLayout是Layout的一部分,那么Google为什么不将其添加到旧的命名空间中? xmlns:android="http://schemas.android.com/apk/res/android"

以及为什么android需要用XML编写全限定名? android.support.constraint.ConstraintLayout为什么不只是ConstraintLayout?作为RelativeLayout?

最佳答案

ConstraintLayout是Layout的一部分,那么Google为什么不将其添加到旧的命名空间中?


这是为平台定义的属性保留的。 ConstraintLayout来自库,而不来自平台。


  以及为什么android需要用XML编写全限定名? android.support.constraint.ConstraintLayout为什么不只是ConstraintLayout?


Android仅知道使用简写的,仅裸类名称的表示法在几个平台定义的程序包中查找视图。 android.support.constraint来自库,而不是平台。

07-24 09:44
查看更多