<merge xmlns:android="http://schemas.android.com/apk/res/android"> <ToggleButton Android:id="@+id/togglebutton1"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text="ToggleButton"/> <TextView android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:layout_marginbottom="20dip"android:layout_gravity="Center_horizontal|bottom"android:padding="12dip"Android:background="#AA000000"Android:textcolor="#ffffffff"Android:text="Golden Gate"/> </merge>
1.merge layouts are similar to framelayout, with the same effect. The merge layout can only be included with the <include> tag. or used by Activity.setcontentview.
When Layoutinflater encounters a <include> that can be included with another layout, and no longer generates viewgroup containers, this element is particularly useful for this tag, it skips it and adds elements from the <merge/> to the <merge/> In the parent element. The reason that activity can be used directly is that the parent element of the activity is Framelayout
2 merge can be included with <include> in other layout, and no more viewgroup containers are generated. That is, it reduces the first layer of layout to optimize layout.
Limit:
<merge/> can only be used as the root tag of an XML layout
· When you inflate a layout file that begins with <merge/>, you must specify a parent ViewGroup, and you must set Attachtoroot to True (see inflate (int, android.view.ViewGroup, Boolean) method).
Use of the Android merge tag