How can I create a ListView
with fixed header and footer?
I don't want the header/footer to scroll with the items in the ListView
.
Is it possible that the header/footer is floating over the ListView
so that the header/footer dont need to have a straight bottom/top background and the ListView
items scrolls below the background of the header/footer view, but still show the first element of the list?
Make the header and footer separate Views which you locate over the top and bottom of the ListView. Then set the opacity for those Views.
http://developer.android.com/reference/android/widget/ListView.html#addHeaderView%28android.view.View%29. Check this for addHeaderView(param).
http://developer.android.com/reference/android/widget/ListView.html#addFooterView%28android.view.View%29. Check this for addFooterView(param).
Example of the method usuage by inlfating a layout @ Android listview with header and footer buttons
You can use addHeaderView and addFooterView for the list to add header and footer.
You can do as what @blackbelt suggested. I have used a relative layout instead of LinearLayout.
Graphical Layout snap shot
create your custom header and footer with your list view code as below
header.xml file
footer.xml file
add where your listview
we can set header and footer in this way also, i am setting header layout above listview and in same way we cans et footer below listview
I solved it by using @blackbelt suggestion and a small ImageView with the source image being transparant with a tile background.
Screenshot from device
Use a
LinearLayout
, add your header upon theListView
and the footer above. Gives theListView layout_weight="1"