Search code examples
androidlistviewfooter

Footer in listview not working properly


I want to implement the heaser and footer in my screen and I have tried the code,but problem is that there should be some space between submit button and footer but in device it showing like button is attached to the footer.One solution I have done is the I have given the hardcode value to scrollview but its not proper way, can someone give me proper solution for this.

My code is

<?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:layout_gravity="center_horizontal"
    android:background="@drawable/bckcolor"
    android:orientation="vertical" >

    <RelativeLayout
        android:id="@+id/upper"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/payment_03" >
    </RelativeLayout>

    <ScrollView
        android:id="@+id/scroll"
        android:layout_width="wrap_content"
        android:layout_height="250dp"
        android:layout_below="@+id/upper"
        android:layout_marginLeft="20dip"
        android:layout_marginRight="10dip"
        android:layout_marginTop="15dip" >

        <RelativeLayout
            android:id="@+id/middle"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/my_border"
            android:orientation="vertical" >

            <EditText
                android:id="@+id/actntlist"
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:hint="Enter Phone number" />

            <EditText
                android:id="@+id/receivercode"
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:layout_below="@+id/actntlist"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:hint="Enter receiver code" />

            <EditText
                android:id="@+id/amount"
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:layout_below="@+id/receivercode"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:hint="Enter amount" />

            <EditText
                android:id="@+id/remarks"
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:layout_below="@+id/amount"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:hint="Enter remarks" />

            <EditText
                android:id="@+id/pin"
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:layout_below="@+id/remarks"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:hint="Enter Pin number" />

            <Button
                android:id="@+id/submit"
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:layout_below="@+id/pin"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:text="submit" >
            </Button>
        </RelativeLayout>
    </ScrollView>

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

        <TextView
            android:id="@+id/foot"
            android:layout_width="fill_parent"
            android:layout_height="40dp"
            android:layout_alignParentBottom="true"
            android:background="@drawable/footer"
            android:text="" >
        </TextView>
    </RelativeLayout>

</RelativeLayout>

Solution

  • You can set the bottom margin to your scroll View, so it will leave some space from the bottom. Try this.

       <ScrollView
            android:id="@+id/scroll"
            android:layout_width="wrap_content"
            android:layout_height="250dp"
            android:layout_below="@+id/upper"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="10dip"
            android:layout_marginTop="15dip"
            android:layout_marginBottom="15dip" >