I'm sure that I'm missing something simple to get this implemented, but have run through every known combination I can come up with to get what I'm looking to do working. I'm trying to have a ListView footer sit at the bottom of the screen when the ListView items do not fill the page.
For example, I have a page with a ListView of three items and a FooterView (using the ListView's addFooterView) I want that footerView to sit at the bottom of the screen. When the ListView contains enough items to scroll the screen, the footerView should sit at the end of the list (not at the bottom of the screen).
The XML I'm trying to use is listed below. Any and all help is much appreciated!
Layout.xml
<?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:background="@+drawable/background">
<ListView
android:id="@+id/menu"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:listSelector="@android:color/transparent"
android:divider="@null">
</ListView></RelativeLayout>
ListViewRow.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
style="@style/Nationwide.menu">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/nav_item"
style="@style/Nationwide.menu.row">
<ImageView
android:id="@+id/image_icon"
style="@style/Nationwide.menu.leftIcon" />
<TextView
android:id="@+id/nav_text"
style="@style/Nationwide.menu.text" />
<ImageView
android:id="@+id/chevron_symbol"
style="@style/Nationwide.menu.rightIcon" />
</LinearLayout>
<View
android:layout_height="1dp"
android:background="@drawable/nav_item_divider_dark" />
<View
android:layout_height="1dp"
android:background="@drawable/nav_item_divider_light" /></LinearLayout>
ListViewFooter.xml
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true">
<View
android:id="@+id/footer_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true" /></RelativeLayout>
Java
LayoutInflater inflater = this.getLayoutInflater();
View footerView = inflater.inflate(R.layout.footer, null);
footerView.findViewById(R.id.footer_image).setBackgroundDrawable(resources.getDrawable(R.drawable.cone_footer));
mMenuListView.addFooterView(footerView);
The things I've tried so far include:
Thanks in advance!
I want that footerView to sit at the bottom of the screen.
That is not how addFooterView()
works.
When the ListView contains enough items to scroll the screen, the footerView should sit at the end of the list (not at the bottom of the screen).
That too is not how addFooterView()
works.
If you want it to scroll with the list (i.e., if the three list items take up the top half of the screen, the footer is right below the three items), then use addFooterView()
...but then the footer always scrolls with the list.
If you want it to not scroll with the list, one approach is to use a RelativeLayout
as your parent, anchor your footer to the bottom of the screen, and have the ListView
sit in between the top and the footer...but then the footer never scrolls.