Android: как разделить экран для TableLayout рядом с LinearLayout? - PullRequest
0 голосов
/ 08 октября 2011

Как я могу разделить экран, чтобы левая половина экрана была линейной, а правая половина - таблицей.

Я пытался применить 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>

1 Ответ

1 голос
/ 08 октября 2011

Дайте идентификатор вашей LinearLayout и добавьте параметр android:layout_toRightOf="@+id/your_linear_layout" в TableLayout. Или вы можете использовать другой LinearLayout вместо RelativeLayout. Если вам не нужно добавлять больше просмотров, LinearLayout может быть лучше.

...