若你在include的layout中的父View,声明了其id,如:
该布局xml命名为: layout_a.xml
id为layout_a
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_a"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/whilte"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
/>
</RelativeLayout>
在其他布局中使用include引用改布局时,就不能再声明id了,那么就会报错。只能声明一次。
以下的使用就是错误的。
<include
android:id="@+id/layout_a"
layout="@layout/layout_a"/>