merge usage

<merge>标签用于减少Android布局中视图树层级,从而优化布局性能。它不能作为LinearLayout的子元素使用,仅能作为XML布局文件的根标签。在使用时,需要指定父ViewGroup,并设置attachToRoot为true。

 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 >

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值