merge:可以让其他的布局直接引用,一般和inClude配套使用。
inClude:加载一个其他的布局进来。
Demo: merge
1 <?xml version="1.0" encoding="utf-8"?> 2 <merge xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" > 5 6 <View 7 android:layout_width="match_parent" 8 android:layout_height="1dip" 9 android:background="#656665" 10 /> 11 12 </merge>
添加merge布局
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:orientation="vertical" > 6 7 <TextView 8 style="@style/text_title_style" 9 android:text="@string/lost_protected_setting_text_01" /> 10 11 <View style="@style/view_divide_line_style" /> 12 13 <RelativeLayout 14 android:layout_width="match_parent" 15 android:layout_height="wrap_content" > 16 17 <TextView 18 android:layout_width="wrap_content" 19 android:layout_height="wrap_content" 20 android:text="@string/lost_protected_setting_text_02" 21 android:textColor="#025086" 22 android:textSize="18sp" /> 23 24 <TextView 25 android:id="@+id/tv_lost_protected_setting_safe_number" 26 android:layout_width="wrap_content" 27 android:layout_height="wrap_content" 28 android:layout_alignParentRight="true" 29 android:textColor="#025086" 30 android:textSize="18sp" /> 31 32 </RelativeLayout> 33 34 <include layout="@layout/line"/> 35 </LinearLayout>