Android在layout xml中使用include
来源:互联网 发布:剑三迪丽热巴捏脸数据 编辑:程序博客网 时间:2024/05/20 04:13
在Android的layout样式定义中,可以使用xml文件方便的实现,有时候为了模块的复用,使用include标签可以达到此目的。例如:
<include layout="@layout/otherlayout"></div>
Android开发的官方网站的说明在这里。
其中,有提到:
Similarly, you can override all the layout parameters. This means that any android:layout_* attribute can be used with the
<include>
tag.意思是任何android:layout_*属性都可以应用在标签中。
如果使用如下代码:
<Relativelayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <Textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/somestring" android:id="@+id/top" /> <include layout="@layout/otherlayout" android:layout_below="@id/top" /></Relativelayout >
发现include
的otherlayout,并没有在如我们预期的在id/top这个TextView下面,而是忽略了android:layout_below属性。经过Google发现,很多人遇到类似的问题。
有解决方法是在include的外面再包一层LinearLayout,如下:
<Linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/top" > <include layout="@layout/otherlayout"></Linearlayout >
在Statckoverflow上找到了更好的解决方法: 解答道:必须同时重载layoutwidth和layoutheight熟悉,其他的layout_*属性才会起作用,否这都会被忽略掉。上面的例子应该写成这样:
<include layout="@layout/otherlayout"> android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_below="@id/top" />
0 0
- Android在layout xml中使用include
- Android在layout xml中使用include
- Android在layout xml中使用include .
- Android在layout xml中使用include
- Android在layout xml中使用include
- Android在layout.xml中使用include
- Android在layout xml中使用include
- Android在layout xml中使用include
- Android在layout xml中使用include 问题
- 【layout】Android中include的使用
- Android的Layout中 使用include
- Android Layout中使用include标签实现UI布局重用
- 【layout】Android中merge和include标签的使用
- Android——layout中使用include复用模块
- Android Layout中使用include标签实现UI布局重用
- android xml中include标签的使用
- android在Layout中使用分割线
- 在AndroidManifest.xml文件中键盘和自适应的android:windowSoftInputMode属性使用 | keyboard,squeezing,layout
- C++容器中勿使用memset,memcpy等
- 64位weblogic11g安装
- linearlayout线性布局属性
- Android中的对话框(二)ProgressDialog
- 【NOI2001】聪明的打字员 - 类似8数码的搜索题
- Android在layout xml中使用include
- MySql索引的原理
- 使用Python脚本将酷狗音乐的缓存文件修改为可播放
- 详解C/C++中预处理器
- IOS从屏幕截图并裁剪压缩到指定宽高
- jquery获取触发方法的对象
- hdu3416
- 【BLE】CC2541之硬件IIC(TMP102温度传感器)
- bfprt算法求最小的k个数