Android布局有2个均匀间隔的按钮

时间:2010-04-08 23:36:57

标签: android android-layout

我的布局正常,带有文本视图的相对布局和两个均匀分布在它下面的按钮。

<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父级可能无用”。

有没有办法在没有表格的情况下进行此布局?

1 个答案:

答案 0 :(得分:11)

转储TableLayoutTableRow,并在其位置使用水平LinearLayout。 “魔法”位于您已经拥有的0dip宽度和1重量中。

相关问题