繁体   English   中英

Android:如何在LinearLayout旁边为TableLayout拆分屏幕?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM