1.概念:
2.属性:
3.代码示例:
(1)布局代码:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:collapseColumns="1"
android:stretchColumns="1,2"
android:shrinkColumns="1">
<!-- android:stretchColumns:用其填充空白部分 -->
<!--这三种属性只能在TableLayout中使用!!!!-->
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:text="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
<Button
android:text="222222222222222222222222222222222222"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
<Button
android:text="3"
android:layout_width="match_parent"
android:layout_height="match_parent">
</Button>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_width="100dp"
android:layout_height="wrap_content">
</EditText>
<Button
android:text="4"
android:layout_width="wrap_content"
android:layout_height="match_parent">
</Button>
</TableRow>
<Button
android:text="单独一行"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</TableLayout>
(2)图片对比:
图一:()
图二:
图三: