Reputation: 4562
In my Java android application I use a listview to display information loading from the SQLite DB And a page footer also there in this page.
The problem is When there are more items loaded to the listview and need to scroll, since footer appears in the bottom of the page, the footer covers the the last item in the listview.
Simply I want to stop overlapping listview items by the footer.
Can any one help me achieve this please. Thanks inadvance.
Edits
<RelativeLayout android:id="@+id/relativeLayout1" android:layout_height="wrap_content" android:layout_width="match_parent">
<ListView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/companylistView"
android:listSelector="@drawable/item_focus_bkg">
</ListView>
<LinearLayout android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:layout_width="match_parent" android:orientation="vertical" android:layout_alignParentBottom="true" android:background="@android:color/darker_gray" >
<TextView android:text="Footer Text"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000" >
</TextView>
</LinearLayout>
</RelativeLayout>
Upvotes: 2
Views: 3106
Reputation: 24031
You should use list footer like this:
View footerView = ((LayoutInflater)getApplicationContext().getSystemService(getApplicationContext().LAYOUT_INFLATER_SERVICE)).inflate(R.layout.listview_footer, null, false);
list.addFooterView(footerView,null,false);
try this:
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical" >
<ListView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/companylistView"
android:listSelector="@drawable/item_focus_bkg" />
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="@android:color/darker_gray" >
<TextView
android:text="Footer Text"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</LinearLayout>
Upvotes: 0
Reputation: 128428
Based on your requirement(And as you haven't posted XML layout here that you have tried so far), i assume and can suggest the following:
android:layout_marginBottom="60dip"
android:layout_above="@+id/footer"
I suggest to you go with 2nd option.
Based on the XML you have posted, try this correct XML layout:
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_height="wrap_content"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ListView android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/companylistView"
android:layout_above="@+id/textView1">
</ListView>
<TextView
android:text="Footer Text"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:layout_alignParentBottom="true">
</TextView>
</RelativeLayout>
Upvotes: 5