Android两个listview垂直使用50%-50%的屏幕高度

Ale*_*lex 3 android listview

我想ListViews在一个屏幕下垂直使用两个屏幕,另外两个ListView同样占用屏幕的50%-50%.我的问题是,我创建了布局,在eclipse(图形布局)看起来很棒,但在设备中它不会占用屏幕的一半.这似乎取决于内容ListView.我该怎么办?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#f0f0f0"
    android:weightSum="1.0">

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dip"
        android:textSize="18sp"
        android:textStyle="bold"
        android:gravity="left"
        android:textColor="#000"
        android:text="Some Text" />

        <ListView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginLeft="10dip"
            android:layout_marginRight="10dip"
            android:layout_weight="0.5"
            android:background="#FB0"
            android:scrollbars="none"
            android:dividerHeight="2dip" />

        <ListView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginLeft="10dip"
            android:layout_marginRight="10dip"
            android:layout_weight="0.5"
            android:background="#FB0"
            android:scrollbars="none"
            android:dividerHeight="2dip" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

ina*_*ruk 10

您应该在设置时介绍LinearLayout和使用. layout_weightlayout_height="0dp"

这是一个例子:

<TextView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

        <ListView
           android:layout_width="fill_parent"
           android:layout_height="0dp"
           android:layout_weight="0.5" />

        <ListView
           android:layout_width="fill_parent"
           android:layout_height="0dp"
           android:layout_weight="0.5" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)