【发布时间】:2011-12-03 09:37:48
【问题描述】:
如何分割屏幕,让屏幕左半边是Linearlayout,右半边是Tablelayout。
我尝试将 layout_weight 设为 1 并将 weightSum 设为 2 应用于 RelativeLayout 包装器。
谁能指导我?
这是我目前得到的:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="2"
>
<LinearLayout android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="@string/hello2" />
</LinearLayout>
<TableLayout
android:id="@+id/Row1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_alignParentRight="true"
>
<TableRow>
<Button android:id="@+id/Modus"
android:text="@string/Mode1"
android:background="@layout/modus_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
/>
<Button android:id="@+id/Modus"
android:text="@string/Mode2"
android:background="@layout/modus_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
/>
</TableRow>
</TableLayout>
</RelativeLayout>
【问题讨论】:
-
它必须是一个RelativeLayout作为包装器吗?此外,当我尝试复制您在 Eclipse 中的内容时,我被告知 layout_weight 属性在 RelativeLayout 中无效。尝试使用水平 LinearLayout 作为包装器?
标签: android layout android-linearlayout android-relativelayout tablelayout