Android TableLayout宽度问题

Vik*_*kas 4 android android-layout android-tablelayout

我正在使用TableLayout来显示数据.当活动调用onCreate()时,将设置右列TextView的文本.

现在,正如您在下图中看到的那样,我的地址文本可以很长并且应该被包装.所以我设置android:layout_width="wrap_content".但它仍然需要一个宽度的屏幕大小来包装数据.我怎样才能克服这个问题?

替代文字

我的xml:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="5px">
    <TableRow>
        <TextView android:text="Job#"
            android:paddingRight="5px" />
        <TextView android:id="@+id/DetailJobNo" />
    </TableRow>
    <TableRow>
        <TextView android:text="Address"
            android:paddingRight="5px" />
        <TextView android:id="@+id/DetailAddress"
            android:layout_width="wrap_content"
            android:text="Address Address Address Address Address Address Address Address "/>
    </TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)

Vik*_*kas 6

添加android:shrinkColumns="1"到TableLayout解决了我的问题.