2012-08-06 70 views
0

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

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

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

,但是当我看到输出表行是不是全幅的到来。它只有包装内容。

输出

Output of layout with half

所以,你能帮我做输出全屏?

回答

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

非常感谢Shaiful ......这正是我想要的。它的工作很好。 – 2012-08-06 10:49:22

相关问题