android的TableLayout布局界面元素填满整个屏幕
16lz
2021-01-23
在做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为例来做演示
和上面的一样这里的android:layout_weight="1"也不能少,这个保证按钮能在横向上铺满屏幕。
完整的布局文件代码如下:
效果如下:
更多相关文章
- Android图表控件MPAndroidChart——曲线图LineChart(多条曲线)动态
- 关于声明文件中android:process属性说明
- View组件之各xml属性
- android 最全的shape属性
- android:cacheColorHint,android:listSelector属性作用
- TextView的drawable属性
- android流式布局热门标签的实现