android的TableLayout布局界面元素填满整个屏幕
来源:互联网 发布:linux删除mysql数据库 编辑:程序博客网 时间:2024/06/11 04:51
在做android界面设计时如果使用到TableLayout布局即表格布局,要想让界面中的控件填满整个屏幕除了要设置TableLayout的属性
android:layout_width="fill_parent" android:layout_height="fill_parent"
还需要设置TableRow的属性为
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"
注意这里的android:layout_weight="1"一定不能忘了,否则子控件的android:layout_height="fill_parent"是不起作用的。
最后就是界面控件的属性了,这里以Button为例来做演示
<Button android:id="@+id/button1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:text="Button" />
和上面的一样这里的android:layout_weight="1"也不能少,这个保证按钮能在横向上铺满屏幕。
完整的布局文件代码如下:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" tools:context=".MainActivity" > <TableRow android:id="@+id/tableRow1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> <Button android:id="@+id/button1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:text="Button" /> </TableRow></TableLayout>
效果如下:
0 0
- android的TableLayout布局界面元素填满整个屏幕
- ScrollView子布局填满整个屏幕
- Android画图之Bitmap填满整个屏幕
- android界面布局----TableLayout(表单布局)
- 【Android】界面布局之TableLayout(表格布局)
- android开发利用tablelayout布局实现登录界面
- android应用程序界面不能铺满模拟器的整个屏幕
- 界面布局-TableLayout
- 界面布局TableLayout+TableRow
- (转)【Android】界面布局之TableLayout(表格布局)
- android recycleview 没有填满屏幕
- android开发学习之-----界面布局 TableLayout + TableRow
- android表格布局TableLayout的使用
- 关于android应用的toolbar(actionbar)不能填满布局解决
- Android布局之TableLayout
- android-TableLayout 表格布局
- tablelayout-android布局
- Android---tableLayout(表单布局)
- HTML5基础教程系列:第3部分,HTML5 API的威力
- C语言的谜题
- 浏览器不兼容
- 第五周作业—有向图邻接表表示及反向图构造
- UNREFERENCED_PARAMETER
- android的TableLayout布局界面元素填满整个屏幕
- python 发送Email程序
- Window Android 学习
- 数组的总结
- OpenCv矩阵操作函数大全 (1.0接口)
- python中的os模块
- Suricata之源代码(二)
- Box2D C++ 教程-跳跃
- asterisk使用MYSQL认证的配置方法