2

I have a list view, editText and button. editText and button are my footer to the listview. What is want is the footer to be positioned at the bottom of the screen and the listview to be scrollable above the footer. My layout is something like this:

<?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">

<ListView
    android:id="@android:id/list"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:>

</ListView>


<EditText
    android:id="@+id/txtType"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_toLeftOf="@+id/add" />

<Button
    android:id="@+id/add"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:onClick="onClick"
    android:text="Add" />
 </RelativeLayout>

enter image description here

I have achieved above picture but my problem is that the listview scrolls below my footer. Footer is like floating over the listview. I want the listview to be scrollable above this footer only. help me

rockstar
  • 1,322
  • 1
  • 20
  • 37
  • Do you want the footer to scroll? – Shubhayu Apr 03 '12 at 10:10
  • see this this post [Android ListView Footer View not being placed on the bottom of the screen](http://stackoverflow.com/questions/3093481/android-listview-footer-view-not-being-placed-on-the-bottom-of-the-screen) – ρяσѕρєя K Apr 03 '12 at 10:11

5 Answers5

7
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ListView
        android:id="@android:id/list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_above="@+id/bbar">

    </ListView>

    <RelativeLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:id="@+id/bbar">

        <EditText
            android:id="@+id/txtType"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_toLeftOf="@+id/add" />

        <Button
            android:id="@+id/add"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:onClick="onClick"
            android:text="Add" />
    </RelativeLayout>
</RelativeLayout>
Sandip Jadhav
  • 7,377
  • 8
  • 44
  • 76
0

Give Editbox and button in another LinearLayout,

<?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">

<ListView
    android:id="@android:id/list"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:>

</ListView>
 <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:gravity="center" >


<EditText
    android:id="@+id/txtType"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_toLeftOf="@+id/add" />

<Button
    android:id="@+id/add"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:onClick="onClick"
    android:text="Add" />
</LinearLayout>
 </RelativeLayout>

Thanks....

user4232
  • 592
  • 1
  • 12
  • 37
0

Wrap Editbox and button in another LinearLayout, . then use alignParentBottom=true property for the Linear Layout .

Relsell
  • 771
  • 6
  • 18
0

check out this this is working for me

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:background="@drawable/login_page_bg"
 android:layout_height="fill_parent"
 >

 <ListView  
     android:id="@android:id/list"
     android:layout_above="@+id/footerlayout"


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



   <RelativeLayout 
    android:id="@+id/footerlayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    >

      <Button
          android:id="@+id/button1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:onClick="onClickAddChild"
          android:text="Add+"/>
  </RelativeLayout>

 </RelativeLayout>
Ravi1187342
  • 1,247
  • 7
  • 14
0

Just add this android:layout_above="@+id/txtType" to your ListView.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <ListView
        android:id="@android:id/list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/txtType"
        android:layout_alignParentTop="true"
        android:="" >
    </ListView>
    <EditText
        android:id="@+id/txtType"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_toLeftOf="@+id/add" />
    <Button
        android:id="@+id/add"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:onClick="onClick"
        android:text="Add" />
</RelativeLayout>
Deva
  • 3,919
  • 1
  • 27
  • 38