匹配所有表格行的高度

Match height of all tablerow

如图所示,我正在尝试填充左侧的短文本以匹配右侧的长文本。 rihtsite 上的长文本会动态变化,因此不会是静态的。

这是我的代码:

        <TableLayout
            android:id="@+id/table"
            android:layout_margin="10dp"
            android:layout_below="@id/avatar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TableRow
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <TextView android:text="short text"
                    android:gravity="center"
                    android:stretchColumns="1"
                    android:layout_width="0px"
                    android:layout_height="wrap_content"
                    android:layout_column="1"
                    android:layout_weight="1"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:padding="5dp"
                    android:background="@drawable/xml_cell_shape"/>
                <TextView android:text="long text is long really really long this is not a lie"
                    android:layout_width="0px"
                    android:layout_height="wrap_content"
                    android:layout_column="2"
                    android:layout_weight="3"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:padding="5dp"
                    android:background="@drawable/xml_cell_shape"/>
            </TableRow>
            <TableRow
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <TextView android:text="short text"
                    android:layout_width="0px"
                    android:layout_height="wrap_content"
                    android:layout_column="1"
                    android:layout_weight="1"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:padding="5dp"
                    android:background="@drawable/xml_cell_shape"/>
                <TextView android:text="medium text not long nor short"
                    android:layout_width="0px"
                    android:layout_height="wrap_content"
                    android:layout_column="2"
                    android:layout_weight="3"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:padding="5dp"
                    android:background="@drawable/xml_cell_shape"/>
            </TableRow>
        </TableLayout>

只需将 TextView 包装在 LinearLayout 中的 TableRow 中。像这样

<TableRow
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="4"
            android:orientation="horizontal">

            <TextView
                android:layout_width="0dip"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@drawable/xml_cell_shape"
                android:gravity="center"
                android:padding="5dp"
                android:text="short text"
                android:textAppearance="?android:attr/textAppearanceMedium"/>

            <TextView
                android:layout_width="0dip"
                android:layout_height="match_parent"
                android:layout_weight="3"
                android:background="@drawable/xml_cell_shape"
                android:padding="5dp"
                android:gravity="center"
                android:text="long text is long really really long this is not a lie"
                android:textAppearance="?android:attr/textAppearanceMedium"/>
        </LinearLayout>
    </TableRow>