1

我在TableRow中有一个 TextView 。有没有办法为这个 TextView 设置一个 FILL_PARENT 宽度?

已编辑:当我有 TableRow 的背景图像时不填充

<TableLayout android:id="@+id/tableLayout1"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <TableRow android:layout_height="wrap_content" android:id="@+id/tableRow1"
        android:layout_width="fill_parent" android:background="@drawable/myImage">
        <TextView android:text="I wrapped!" android:id="@+id/textView1"
            android:layout_width="fill_parent" android:background="@color/white"
            android:layout_height="wrap_content"></TextView>
    </TableRow>
</TableLayout>
4

1 回答 1

1

您的链接回答了您的问题。

TableRow 的子项不需要在 XML 文件中指定 layout_width 和 layout_height 属性。TableRow 始终强制这些值分别为 MATCH_PARENT 和 WRAP_CONTENT

FILL_PARENTMATCH_PARENT在 API 级别 8 及更高版本中重命名)

TextView应该自动是FILL_PARENTwhich is MATCH_PARENT

于 2011-06-24T19:03:19.087 回答