作者:杰v杰123_246 | 来源:互联网 | 2023-09-16 13:48
篇首语:本文由编程笔记#小编为大家整理,主要介绍了android 关于表格布局的认识相关的知识,希望对你有一定的参考价值。
表格布局(TableLayout)
![技术分享](https://img6.php1.cn/3cdc5/c2ee/525/b19ccdad3cccb805.jpeg)
使用的知识点有:
控件
TableRow:为这个表格添加一行
table的特殊属性
android:layout_column:确定此表格的列数
android:stretchColumns:确定拉伸的列
android:shrinkColumns:确认压缩的列
table中控件可添加的属性
android:layour_column:指定此控件具体的位置
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="2">
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="Button" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="2"
android:text="Button" />
TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="2"
android:text="Button" />
TableRow>
TableLayout>
上述布局的代码