Back

android - layout中的include,merge 和 其他

发布时间: 2017-08-21 00:04:00

实际上我用过的只有include.

很简单。 当前xml可以include 某个其他的xml 

要求其他的xml的根节点声明中,必须有 xmlns:android="http://schemas.android.com/apk/res/android" 这句话。

下面是个例子:

当前xml : 

<LinearLayout ... >
    <include layout="@layout/partia"/>
</LinearLayout>

被include的xml (可以认为是某个片段)

<FrameLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    ......... 其他代码
</FrameLayout> 

就可以了。

Back