Android中文API- <merge/> 标签
2016-04-25 17:55
447 查看
Use <merge/> tag这<merge/>标签,帮助我们在include一个布局的时候,消除多余的View Groups,例如,你的主布局文件是一个竖直的linearlayout。<Linearyoutxmlns:android=http://schemas.android.com/apk/res/androidAndroid:layout_width=”match_parent”Android:layout_height=”match_parent”Android:orientation = ”vertical”> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="text"/> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="text"/> <include Layout=”@layout/ok_no_pannel”/></ Linearyout>此时:分析以下ok_no_pannel.xml,文件的写法:<Linearyoutxmlns:android=http://schemas.android.com/apk/res/androidAndroid:layout_width=”match_parent”Android:layout_height=”match_parent”Android:orientation = ”vertical”> <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"/></ Linearyout >以上的文件的写法,你会发现一旦include执行完成,你会发现,有一层的LinearLayout是没用的,通过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>Now,当你通过include标签将一个布局文件嵌入另一个布局文件中,系统会忽略merge标签,直接将两个button元素放在布局文件中,来代替include标签的位置。作者有话说:如果您需要Android中文API,请扫一扫下面的二维码,您的关注,就是我的动力。
相关文章推荐
- android进程间通信:AIDL
- Android MVP&依赖注入&单元测试
- Android百度地图,定位图标随着方向的改变而改变
- android图片的异步加载和双缓存学习笔记——DisplayImageOptions
- Android开源项目
- Android触摸事件分发机制
- android 在一个应用中启动另一个应用
- android webkit 内核
- Android捕获全局异常信息并实现上传
- OpenCV4Android(AS)-1
- Android 代码混淆实战
- Android学习之友盟5.0推送,分享踩坑总结
- Ubuntu安装Android Studio出现错unable to run mksdcard sdk tool
- Android-Notification推送栏通知
- Android开源项目分类汇总
- Android之Glide使用详解--集成、配置、使用、特性
- android 唤醒锁定屏幕和锁屏状态下点亮屏幕,并弹出闹钟提示信息
- android studio 导入工程篇(2)
- android动画解析 之补间动画和帧动画
- android app开发用好styles.xml==>方便,简洁明了,再也不用晕冗繁代码啦