使用include标签引入布局
来源:互联网 发布:如何雇佣网络水军 编辑:程序博客网 时间:2024/04/26 00:12
正文
在layout的布局文件中为了复用,会使用到
include
来引入布局模块,如下
<include layout="@layout/xml_plus" />
在如下看似合理的代码片中,并没有达到预期的效果
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/tv" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="defualt" /> <include layout="@layout/xml_plus" android:layout_below="@+id/tv" /> <!-- 实际覆盖在TextView上层,并没实现below的效果 --></RelativeLayout>
同时AndroidStudio会给出错误提示.
Layout parameters specified on an <include> tag will only be used if you also override layout_width and layout_height on the <include> tag; otherwise they will be ignored.
如上提示引导,我们重载
layout_width
和layout_height
就能使include
正确的引入外部布局.<include layout="@layout/xml_plus" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/tv" />
以上。如有错误和疑问,欢迎指正提出。 catface.wyh@gmail.com
0 0
- 使用include标签引入布局
- 布局文件的引入<include>标签的使用
- android布局标签<include />使用
- 布局文件-include标签使用
- include引入mergre布局
- Android 布局中的include标签使用
- Android中使用include标签和merge标签重复使用布局
- Android中使用include标签和merge标签重复使用布局
- Android Layout中使用include标签实现UI布局重用
- android_应用开发之(使用<include>标签重用布局)
- 在android布局中使用include和merge标签
- 在android布局中使用include和merge标签
- 在android布局中使用include和merge标签
- 在android布局中使用include和merge标签
- 在android布局中使用include和merge标签
- 在android布局中使用include和merge标签
- 【转】在Android布局中使用include和merge标签
- 在android布局中使用include和merge标签
- Android studio导入第三方项目(以Volley为例)
- linux环境编程之 fork() || fork()
- [疯狂Java]TCP:TCP协议的概念、Socket通信、超时等待
- 15.UIDynamic 物理引擎
- 学习google编程风格
- 使用include标签引入布局
- 精华阅读第 9 期 |滴滴出行 iOS 客户端架构演进之路
- Android startActivity源码详解
- xfire web service导致cpu100%问题分析
- LintCode 删除链表中等于给定值val的所有节点
- Android 截屏并保存
- css 长单词不换行溢出容器的解决方法 word-wrap与word-break
- centos配置mutt跟msmtp发送邮件
- phpredis中文手册——《redis中文手册》 php版