2013-05-06 58 views
0

I'm使用由側2的表側的的LinearLayout和噹噹屏幕寬度的兩個填充50%。在LinearLayout下面,有一個RelativeLayout與其中的另一個表。對齊不同佈局的表格?

事情是這樣的:

<LinearLayout> 
     <TableLayout> 
      <TableRow> 
      ... 
      </TableRow> 
     </TableLayout> 

     <TableLayout> 
      <TableRow> 
      ... 
      </TableRow> 
     </TableLayout> 
</LinearLayout> 

<RelativeLayout> 

     ... some views ... 

     <TableLayout> 
      <TableRow> 
      ... 
      </TableRow> 
     </TableLayout> 
</RelativeLayout> 

現在我想在RelativeLayout的表有相同的寬度在LinearLayout中的第一個表。我認爲我可以用android:layout_alignRight="@+id/Linearlayout_table1"做到這一點,但那是行不通的。

那麼,有沒有辦法做到這一點?

+1

對於物業工作所引用的佈局應該被包含在裏面RelativeLayout的。 – ZhDev 2013-05-06 16:51:48

+0

以及關於在RelativeLayout..r中添加TableView之後剩下的剩餘空間的信息。 – bakriOnFire 2013-05-06 17:02:37

回答

0

可以替代的RelativeLayout的使用的LinearLayout,幷包括一個空元素,以提供正確的權重。注意:將layout_height設置爲任何你想要的。

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 

     <TableLayout 
      android:layout_width="0dp" 
      android:layout_height="300dp" 
      android:layout_weight="1" /> 

     <TableLayout 
      android:layout_width="0dp" 
      android:layout_height="300dp" 
      android:layout_weight="1" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 

     <TableLayout 
      android:layout_width="0dp" 
      android:layout_height="300dp" 
      android:layout_weight="1" /> 

     <View 
      android:layout_width="0dp" 
      android:layout_height="0dp" 
      android:layout_weight="1" /> 
    </LinearLayout>