I have a ListView which can contain any number of items. When it uses less than the whole height of the screen I want to show a footer which fills the remaining space.
The footer is just a tiled image. I can't just set it as the background of the ListView or its container, because the list items are partially transparent and it must be the main background and not the footer visible through them.
Adding the footer view works fine if the footer is of a fixed height, but if the fixed height is more than the remaining height then the ListView scrolls unnecessarily.
Making the footer view fill_parent seems to have no effect, it's just invisible.
Putting the footer view into the parent layout also has no effect, because the ListView seems to fill the whole height unless it's given a fixed layout_height value.
Is this possible?
Try setting the layout weight to one, or check out trying a merge view: http://android-developers.blogspot.com/2009/03/android-layout-tricks-3-optimize-by.html
Put the ListView inside of another layout set the expand to fill the screen.
A LinearLayout works best for this.
Something like this:
<LinearLayout android:layout_height="match_parent"
android:layout_width="match_parent" >
<ListView android:layout_height="match_parent"
android:layout_width="match_parent" >
...
</ListView>
</LinearLayout>
This should fill the LinearLayout to the bottom of the screen. You can use this behavior to control how your View looks.
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With