为何要使用<merge\>标签

来源:互联网 发布:淘宝手绘素描造假 编辑:程序博客网 时间:2024/06/05 16:50

from : http://blog.csdn.net/tanjunjie621/article/details/7320659 


在使用include复用layout时,可能复用的layout有个view group,然后这个view group又被嵌套别的view group里,这样就增加了view的深度,影响运行的速度,而这种嵌套不是必须的。

因此可以使用<merge\>标签,它将它里面嵌套的view直接include到其父layout中,而没有再加一层view group,因此减小了深度,提高了速度


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>

原创粉丝点击