2010-04-08 99 views
7

我有這種可以正常工作的佈局,文本視圖和兩個按鈕之間均勻分佈的相對佈局。帶有2個均勻間隔按鈕的Android佈局

<RelativeLayout android:id="@+id/entrypopup" 
      android:layout_width="fill_parent" 
    android:layout_height="wrap_content" android:padding="5px" 
    android:visibility="gone" 
    android:layout_below="@+id/ad" 
    android:background="#80000000"> 
    <TextView android:id="@+id/title" android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:text="Entry Popup..." 
     android:textColor="#ffffffff" 
     android:textSize="20sp" /> 
    <TableLayout android:id="@+id/TableLayout01" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/title"> 
     <TableRow android:layout_weight="1"> 
      <Button android:id="@+id/buttonVisit" android:text="View" 
       android:layout_height="fill_parent" 
       android:layout_width="0dip" 
       android:layout_weight="1"/> 
      <Button android:id="@+id/buttonCancel" android:text="Cancel" 
       android:layout_width="0dip" 
       android:layout_weight="1" 
       android:layout_height="fill_parent"/> 
     </TableRow> 
    </TableLayout> 
</RelativeLayout> 

但運行layoutopt它說「這個TableRow佈局或它的TableLayout父項可能是無用的」。

有沒有辦法做到這種佈局,然後沒有表?

回答

11

轉儲TableLayoutTableRow,只是使用水平的LinearLayout在他們的位置。 「魔術」是在你的0dip寬度和1重量,你已經有。

+1

你真棒;)有按鈕,下面的文本和文本可能會有所不同的大小,所以佈局沒有適當的,0dip沒有把戲:) – Warpzit 2011-11-09 08:47:22