这个就和Html里的table属性差不多,只不过,这个table的参数不是很,常用参数只有几个。
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:collapseColumns="4"
android:stretchColumns="2"
android:shrinkColumns="1">
<TableRow>
<androidx.appcompat.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="一个按钮1"/>
<androidx.appcompat.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="一个按钮2"/>
<androidx.appcompat.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="一个按钮3"/>
<androidx.appcompat.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="一个按钮4"/>
<androidx.appcompat.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="一个按钮5"/>
</TableRow>
<TableRow>
<androidx.appcompat.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="一个按钮1"/>
<androidx.appcompat.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="一个按钮2"/>
<androidx.appcompat.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="一个按钮3"/>
</TableRow>
<TableRow>
<androidx.appcompat.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="一个按钮1"
android:layout_column="1"
android:layout_span="2"/>
</TableRow>
</TableLayout>