【问题标题】:Set a FILL_PARENT width to a TextView, which is inside of a TableRow将 FILL_PARENT 宽度设置为 TextView,它位于 TableRow 内部
【发布时间】:2011-09-22 06:47:56
【问题描述】:

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

已编辑:当我有 TableRow 的 backgroundImage 时不填充

<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>

【问题讨论】:

    标签: android textview width tablerow fill-parent


    【解决方案1】:

    您的link 回答了您的问题。

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

    FILL_PARENT(在 API 8 级及更高版本中重命名为 MATCH_PARENT)

    您的TextView 应自动为FILL_PARENT,即MATCH_PARENT。

    【讨论】:

    • @coffee:哦,我明白你现在在说什么了。感谢您的编辑。
    • 我只是用 LinearLayout 替换了我所有的 TableRows。工作正常
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-04
    • 2016-04-01
    • 1970-01-01
    • 2013-12-18
    • 1970-01-01
    • 2011-10-05
    • 2011-03-12
    相关资源
    最近更新 更多