tags:

views:

54

answers:

2

Hi Everybody,

I am using two ListView in a screen. I want to divide the height of each ListView but I want it to be screen independent. For this I need to know the Height of the screen. I am using xml to do this. Can any one please help me to achieve this?

Thank You Deepak

A: 

Try setting the layout height of the views to "fill parent" and layout weight to 1.

Asahi
A: 

Try this:

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
>
  <ListView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
  />
  <ListView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
  />
</LinearLayout> 

The important parts are having the ListViews android:layout_height="fill_parent" and android:layout_weight="1" and the LinearLayout android:orientation="vertical"

Documentation for more information about the layout_weight attribute.

Qberticus