2010-04-08 96 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