merge usage

 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 parent ViewGroup and you must set attachToRoot to true (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 >

你可能感兴趣的:(merge usage)