2011-09-26 105 views
0

我的TableLayouts中的列寬有問題。這是情況,我有多個TableLayouts需要對齊在一起,問題是他們在不同的XML文件(多次膨脹同一個),每個人都有一個TableLayout。具有相同列的兩個TableLayout

這是XML

這是我怎麼也想擁有它的圖像。

enter image description here

我希望有人能幫助我。重要的是要知道,每行(TableLayout)都在它自己的XML中,並且我無法將TableLayout放置在這些XML之外。

回答

0

如果您的表格只有兩列,則可能更容易使用線性佈局,併爲LinearLayout的每個成員指定layout_weight。這裏有一個例子:

<LinearLayout android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:weightSum="2"> 
     <TextView android:id="@+id/txt1" 
      android:layout_weight="1" 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:text="Buy"/> 

     <TextView android:id="@+id/txt2" 
      android:layout_weight="1" 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:text="Share"/> 
</LinearLayout> 

你只需要確保該layout_weight S上的各個觀點款項高達父ViewGroup中的weightSum總和。

相關問題