views:

27

answers:

1

I am using LinearLayout to display ListView

  1. Adding Button at the Top.
  2. Then adding Listview bellow the button.
  3. Problem is that Listview take the entire screen at the time of scroll.
  4. At the time of scroll the first cell of the ListView went in the Background of the button.

Is there any solution to strict the List below the button?

A: 

You could try something like that (that's what I use:

<?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">
  <Button android:id="@+id/yourbutton"
    android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
  <LinearLayout android:orientation="vertical"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:layout_below="@+id/yourbutton" >
    <ListView android:id="@android:id/list" android:layout_width="fill_parent"
        android:layout_height="fill_parent" />
  </LinearLayout>
</RelativeLayout>

And the list is supposedto scroll below your button, but display properly at the beginning...

Sephy
Is the LinearLayout still necessary when using RelativeLayout?
MrSnowflake
Well I don't think it IS COMPULSORY, but quite handy if you want more than a button at the top of your list...(I had an edittext too).In this case, a LinearLayout would do the trick too if you set it on orientation:"vertical" I think
Sephy