2011-07-31 67 views
0

再次:我。TableLayout,文本 - 右对齐

我有一个TableLayout(http://imgur.com/XYdcg)为我的“SingleItemAdvancedView”我怎么称呼它;) 事情是,我想要的数据[TextViews没有字符串* Lbl as android:text set](所以不是类似于:“name:”,“id:”等)的描述显示在整个显示的右侧,而不是像现在这样在左边的表格旁边)。我试图将布局与右侧对齐,以及仅布局文本(仅限layout_gravity和gravity)。一切都不起作用。我的宽度都设置为fill_parent,所以我根本不明白为什么。需要帮助!谢谢!

我对活动的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"> 


    <TableRow> 
    <TextView android:text="@string/idLbl" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       /> 
    <TextView android:text="" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/itemidv" /> 
    </TableRow> 
    <TableRow> 
    <TextView android:text="@string/nameLbl" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 
    <TextView android:text="" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/namev" /> 
    </TableRow> 
    <TableRow> 
    <TextView android:text="@string/amountLbl" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 
    <TextView android:text="" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/amountv" /> 
    </TableRow> 
    <TableRow> 
    <TextView android:text="@string/unitLbl" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 
    <TextView android:text="" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/unitv" /> 
    </TableRow> 
    <TableRow> 
    <TextView android:text="@string/ppuLbl" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 
    <TextView android:text="" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/ppuv" /> 
    </TableRow> 
    <TableRow> 
    <TextView android:text="@string/totalLbl" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 
    <TextView android:text="" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/totalv" /> 
    </TableRow> 
    <TableRow> 
    <TextView android:text="@string/commentLbl" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 
    <TextView android:text="" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/commentv" /> 
    </TableRow> 
    <TableRow> 
    <TextView android:text="@string/enterqrLbl" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 
    <TextView android:text="" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/qrcodev" /> 
    </TableRow> 
    <Button android:text="@string/delete" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/deleteItemBtn" 
      android:layout_marginTop="20dp" 
      android:onClick="btnListener" /> 
</TableLayout> 

回答

0

你可以添加机器人:stretchColumns = “0” 到TableLayout。所以,你会是这样的:

<TableLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:stretchColumns="0"> 

如果你想同时列舒展同样可以使用“*”,而不是“0”。

+0

完美地工作。巨大的thx! – Aeefire