android表格布局如何直接将行置底
时间: 2023-12-25 10:06:55 浏览: 22
在Android中,可以使用TableLayout和TableRow来实现表格布局。要将行置于表格的底部,可以在TableRow中使用`android:layout_gravity="bottom"`属性。以下是一个示例:
```xml
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*">
<TableRow>
<TextView
android:text="Header 1"
android:layout_column="1" />
<TextView
android:text="Header 2"
android:layout_column="2" />
<TextView
android:text="Header 3"
android:layout_column="3" />
</TableRow>
<TableRow>
<TextView
android:text="Row 1, Column 1"
android:layout_column="1" />
<TextView
android:text="Row 1, Column 2"
android:layout_column="2" />
<TextView
android:text="Row 1, Column 3"
android:layout_column="3" />
</TableRow>
<TableRow
android:layout_gravity="bottom">
<TextView
android:text="Row 2, Column 1"
android:layout_column="1" />
<TextView
android:text="Row 2, Column 2"
android:layout_column="2" />
<TextView
android:text="Row 2, Column 3"
android:layout_column="3" />
</TableRow>
</TableLayout>
```
在上面的示例中,第二个TableRow的`android:layout_gravity`属性被设置为`bottom`,这将使其出现在表格的底部。