我想制作一个可重复使用的表格布局,其中我有 3 行,最后一行仅包含 1 个元素,而前两行各包含 2 个元素。
现在,问题是,尽管对每一行赋予相同的权重,但表格布局中的行的高度并不相同。
底行占用了太多空间。
以下是布局内容:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="3"
>
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:weightSum="2" >
<TextView
android:id="@+id/txtvw_age"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/age" >
</TextView>
<TextView
android:id="@+id/txtvw_roll_no"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/roll_no" >
</TextView>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:weightSum="2" >
<TextView
android:id="@+id/txtvw_standard"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/standard" >
</TextView>
<TextView
android:id="@+id/txtvw_section"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/section" >
</TextView>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
>
<TextView
android:id="@+id/txtvw_ct_name"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="@string/ct_name" >
</TextView>
</TableRow>
</TableLayout>