0

这是我的布局,我想通过编码将表格行添加到表格布局中。

布局.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/bgblack"
    android:orientation="vertical" >
    <ScrollView
        android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/linearLayout1" >

    <RelativeLayout
            android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/bgblack"
        android:orientation="vertical" >
    <TextView
            android:id="@+id/section_phone"
                android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/linearLayout1"
                android:background="@color/Grey"
            android:padding="2dp"
            android:text="@string/section_phone"
                android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="@android:color/white"
            android:textStyle="bold" />
        <RelativeLayout
            android:id="@+id/detail_phone"
                android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/section_phone" >
                <TableLayout
                android:id="@+id/list_phone"
                    android:layout_width="fill_parent"
                android:layout_height="wrap_content" >
            </TableLayout>
        </RelativeLayout>
        </RelativeLayout>
</ScrollView>
</RelativeLayout>

表格行.xml

<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
    <LinearLayout
        android:id="@+id/details"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
        <TextView
            android:id="@+id/detail_phone_title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="@color/Blue" />
        <TextView
            android:id="@+id/detail_phone_subtitle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:drawableRight="@drawable/ic_contact_call"
            android:padding="5dp"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@android:color/white" />
    </LinearLayout>
</TableRow>

但是当我看到输出表行没有全宽时。它只带有包装内容。

输出

一半的布局输出

那么你能帮我全屏输出吗?

4

1 回答 1

0

拉伸选定的列将解决您的问题。请参阅此链接。TableLayout.html#attr_android:stretchColumns

<!-- The zero-based index of the columns to stretch. -->
<TableLayout
        android:id="@+id/list_phone"
        android:stretchColumns="0"  
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    </TableLayout>
于 2012-08-06T10:37:38.547 回答