添加“表格布局”代码,查看运行效果。
实验代码:
<?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:stretchColumns="2"
tools:context=".MainActivity">
<TableRow>
<Button android:text="按钮一"/>
<Button android:text="按钮三"
android:layout_column="2"/>
</TableRow>
<TableRow>
<Button android:text="按钮四"/>
<Button android:text="按钮五"/>
<Button android:text="按钮六"/>
</TableRow>
<TableRow>
<Button android:text="按钮七"/>
<Button android:text="按钮八"
android:layout_span="2"/>
</TableRow>
</TableLayout>
实验结果: