开发者

Android: how to split a screen for a TableLayout next to a LinearLayout?

开发者 https://www.devze.com 2023-04-12 02:42 出处:网络
How can I split the screen so that the left half of the screen is a Linearlayout and the right half is a Tablelayout.

How can I split the screen so that the left half of the screen is a Linearlayout and the right half is a Tablelayout.

I've tried applying a layout_weight of 1 to both and a weightSum of 2 to the RelativeLayout wrapper.

Can anyone guide me?

This is what I got so far:

<?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 andro开发者_如何学Pythonid: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>


Give an id to your LinearLayout and add android:layout_toRightOf="@+id/your_linear_layout" parameter to your TableLayout. Or you may use another LinearLayout instead of RelativeLayout. If you don't need to add more views LinearLayout could be better.

0

精彩评论

暂无评论...
验证码 换一张
取 消