2012-09-18 50 views
0

我有這個表格佈局,其中第一行兩行有兩行,我在第三行(customerAddress)有一行,我想要對齊並佔據所有空間。我怎樣才能做到這一點。我試過gravity = right,但沒有運氣。TableLayout問題

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 

<TableLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:stretchColumns="*" > 

    <TableRow> 

     <TextView 
      style="@style/CustomerLabelTextView" 
      android:gravity="right" 
      android:text="@string/customerCode" /> 

     <TextView 
      style="@style/CustomerLabelTextView" 
      android:gravity="right" 
      android:text="@string/customerName" /> 
    </TableRow> 
    <TableRow> 

     <TextView 
      android:id="@+id/customerCode" 
      style="@style/CustomerTextView" 
      android:gravity="right" /> 

     <TextView 
      android:id="@+id/customerName" 
      style="@style/CustomerTextView" 
      android:gravity="right" /> 
    </TableRow> 

    <TableRow> 

     <TextView 
      style="@style/CustomerLabelTextView" 
      android:gravity="right" 
      android:text="@string/customerAddress" /> 
    </TableRow> 
    <TableRow> 

     <TextView 
      android:id="@+id/customerAddress" 
      style="@style/CustomerTextView" 
      android:gravity="right" /> 
    </TableRow> 

    <TableRow> 

     <TextView 
      style="@style/CustomerLabelTextView" 
      android:gravity="right" 
      android:text="@string/OrganizationName" /> 

     <TextView 
      style="@style/CustomerLabelTextView" 
      android:gravity="right" 
      android:text="@string/POBox" /> 
    </TableRow> 

    <TableRow> 

     <TextView 
      style="@style/CustomerLabelTextView" 
      android:gravity="right" 
      android:text="@string/phone" /> 

     <TextView 
      style="@style/CustomerLabelTextView" 
      android:gravity="right" 
      android:text="@string/fax" /> 
    </TableRow> 
</TableLayout> 

+0

請給出更多信息併發布您的styles.xml文件。 –

+0

'<樣式名稱= 「CustomerAddressTextView」> <項名稱= 「機器人:layout_width」> FILL_PARENT <項目名= 「機器人:layout_height」> WRAP_CONTENT <項目名= 「機器人:TEXTSIZE」> 16SP <項目名稱= 「機器人:文字顏色」> @機器人:顏色/白色 <項目名= 「機器人:layout_margin」> 5DP <項目名= 「機器人:背景」> @繪製/ textview_border ' – ZAJ

+0

任何人..請幫助 – ZAJ

回答

2

好,我知道它的工作。對於那些可能偶然發現這個問題的代碼,我在下面添加了代碼

<TableRow 
     android:gravity="right" > 


     <TextView 
      android:id="@+id/customerAddress" 
      style="@style/CustomerTextView" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="1.0" 
      android:gravity="right" /> 

    </TableRow>