The <merge />
was created for the purpose of optimizing Android layouts by reducing the number of levels in view trees
You could not apply this trick if your layout was using a LinearLayout
as its root tag for instance
<merge />
can only be used as the root tag of an XML layout- When inflating a layout starting with a
<merge />
, you must specify a parentViewGroup
and you must setattachToRoot
totrue
(see the documentation of the inflate() method)
< merge xmlns:android = "http://schemas.android.com/apk/res/android" > < include layout = "@layout/okcancelbar_button" android:id = "@+id/okcancelbar_ok" /> < include layout = "@layout/okcancelbar_button" android:id = "@+id/okcancelbar_cancel" /> </ merge >