I would like to use two ListViews in one screen vertically one below the other and also the two ListView equally take 50%-50% of the screen. My problem is, I created the layout, in eclipse (graphical layout) looks great but in the device it wont take the half of the screen. It seems depends of the content of the ListView. How can I do it right ??
<?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>
You should introduce
LinearLayoutand uselayout_weight, while settinglayout_height="0dp".Here is an example: