Android布局优化之merge(二)


Android布局优化之Include(一)

Android布局优化之ViewStub(三)


merge减少视图层级

    merge标签在UI的结构优化中起着非常重要的作用,它可以删减多余的层级,优化UI。merge多用于替换FrameLayout或者当一个布局包含另一个时,merge标签消除视图层次结构中多余的视图组。例如你的主布局文件是垂直布局,引入了一个垂直布局的include,这是如果include布局使用的LinearLayout就没意义了,使用的话反而减慢你的UI表现。这时可以使用merge标签优化。

<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>

当添加该布局文件时(使用include标签),系统忽略merge节点并且直接添加两个Button

更多相关文章

  1. [读书笔记]布局的屏幕适配常用方法
  2. Android布局优化之ViewStub(三)
  3. 【入门篇】Android学习笔记——常用布局
  4. [翻译] Android是怎样绘制视图的
  5. Android UI之RelativeLayout(相对布局)
  6. Android Layout布局文件里的android:layout_height等属性为什么.

随机推荐

  1. Android通知栏图标显示网络图片
  2. android camera根据屏幕图像大小设置显示
  3. Android BaseAdapter基本使用及数据刷新
  4. Android 数字格式化
  5. android自定义dialog样式
  6. android 获取音乐文件的内置专辑图片
  7. android 10 system app 读取sysfs_leds a
  8. 阿里技术沙龙第17期·杭州站-无线技术专
  9. Android 实现微信登录
  10. Android用开发者模式进行调试时出现的问