<merge />
Tags remove redundant viewgroup at the UI level when you nest Layout. For example, if you have a layout that is a vertical linearlayout that contains two consecutive view that can be reused in another layout, then you would do a linearlayout to include the two view for reuse. However, when using one linearlayout as the root node of another linearlayout, this nesting linearlayout does not make sense except to slow down your UI performance.
To avoid this situation, you can <merge>
replace the root node of the reusable Layout with elements. For example:
<merge xmlns:android="http://schemas.android.com/apk/res/android"> <Button android:layout_width="fill_parent"Android:layout_height="wrap_content"Android:text="@string/add"/> <Button android:layout_width="fill_parent"Android:layout_height="wrap_content"Android:text="@string/delete"/></merge>
Now, when you want to include this layout in another layout (and use a <include/>
label), the system ignores the <merge>
label and puts two buttons directly into layout <include>
is located.
Android Use <merge> tags