android merge 标签的使用
2015-05-30 14:58
537 查看
<merge xmlns:android="http://schemas.android.com/apk/res/android"> <ToggleButton android:id="@+id/toggleButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="ToggleButton" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="20dip" android:layout_gravity="center_horizontal|bottom" android:padding="12dip" android:background="#AA000000" android:textColor="#ffffffff" android:text="Golden Gate" /> </merge>
1.merge布局 和FrameLayout类似,相同的效果.不同的是 merge布局只能被<include>标签包含. 或者Activity.setContentView所使用.
当LayoutInflater遇到能被其他layout用<include>包含进去,并不再另外生成ViewGroup容器,本元 素也特别有用这个标签时,它会跳过它,并将<merge />内的元素添加到<merge />的父元素里. Activity能直接使用的原因是Activity的父元素是FrameLayout
2 merge 能被其他layout用<include>包含进去,并不再另外生成ViewGroup容器.就是说,会减少一层layout到达优化layout的目的
限制:
<merge />只能作为XML布局的根标签使用
· 当Inflate以<merge
/>开头的布局文件时,必须指定一个父ViewGroup,并且必须设定attachToRoot为true(参看inflate(int,
android.view.ViewGroup, Boolean)方法)。
相关文章推荐
- Error android.text.StaticLayout.calculateEllipsis(StaticLayout.java:783)
- opencv for android 教程
- Android图片内存优化的几点心得
- 修复 XE8 for Android 方向传感器 headingX,Y,Z 不会动的问题
- android关于清除listView(removeAllView)的所有子view的方法
- Android Shape
- Android实战简易教程-第二枪(Spinner下拉级联效果)
- Android Stdio 引入自定义framework.jar 自定义framework-res.apk 中 attr
- [Android] Android开发优化之——使用软引用和弱引用
- Android 开发工具类 27_多线程下载大文件
- Android中Gallery和ImageSwitcher的使用
- Android多窗体退出
- Android开发优化之——对Bitmap的内存优化
- Android 分析android 客户端保持session 不过期的方式
- Android实战技巧:深入解析AsyncTask
- 【Android】emulator命令
- Android优化技术详解-第五章 Android内存系统(笔记)
- 2015-google I/O大会综述:Android M、Android Studio、云端测试工具
- Android使用Catmull_Rom插值算法画光滑曲线图
- Android数据存储-文件操作