[英]Android: how to split a screen for a TableLayout next to a LinearLayout?
如何分割屏幕,使屏幕的左半部分是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>
為您的LinearLayout提供一個ID,然后將android:layout_toRightOf="@+id/your_linear_layout"
參數添加到您的TableLayout中。 或者,您可以使用其他LinearLayout代替RelativeLayout。 如果您不需要添加更多視圖,則LinearLayout可能會更好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.