0

我一直在玩弄很多不同的布局结构,但似乎找不到最适合我的解决方案的布局结构。

基本上我需要 3 行,每行占据设备的 33%(高度)(在横向模式下)。我认为这是完美的,但我似乎无法找到一种方法来指定 a 的高度。我可能在某处忽略了一个属性,但我在文档中找不到它。我也认为这是一种选择,但在玩了一会儿之后,我也不确定这是否是最好的解决方案。

能完成我需要的吗?我将在我的行中指定其他布局(主要是相对布局),但我只需要核心结构为 3 行,每行 33% 高度。

编辑 - 添加代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rellay"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/table_background">
    <LinearLayout
        android:layout_weight="1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <Button
            android:id="@+id/connect"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Connect To Server" />
    </LinearLayout>
    <LinearLayout
        android:layout_weight="1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TextView 
            android:id="@+id/label"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:scrollbars="vertical"
            android:maxLines="6"
            android:textColor="#FFFFFF" />
    </LinearLayout>
    <LinearLayout
        android:layout_weight="1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:stretchColumns="1">
            <TableRow>
                <RelativeLayout
                    android:id="@+id/cardssection"
                    android:layout_column="1" />
                <Button
                    android:id="@+id/submitcards"
                    android:gravity="right"
                    android:maxWidth="10px"
                    android:text="Submit Cards"
                    android:layout_below="@id/label" />
            </TableRow>
        </TableLayout>
    </LinearLayout>     
</LinearLayout>
4

1 回答 1

1

看看这里如何用两个相等的LinearLayouts分割屏幕?. 您只需要在解决方案中再添加一行。注意顶层 LinearLayout 中的 android:orientation="vertical"。

于 2010-08-19T20:49:42.877 回答