How to have a Fixed header with a ListView scrollable body?

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

How to have a Fixed header with a ListView scrollable body?

Postby pcm2a » Tue Dec 08, 2009 6:25 pm

I have a ListActivity with a custom view for each row in the list which works great. What I would like to add is a header onto this list that remains on the screen at all times.

A great example, that everyone has seen, of this is in the Astro file manager. He has one row at the top that is always on the screen, and below that you scroll through your files.

Any idea what combination of stuff he is using?
Posts: 27
Joined: Tue Aug 11, 2009 4:54 pm


Postby achie1266 » Tue Dec 08, 2009 6:45 pm

I am working onthe same thing and am trying to implement it using addHeaderView defined in the ListView class.
Hope someone can show you a better example, but for now this may help you to proceed. I will post the solution if I get it working.
User avatar
Master Developer
Master Developer
Posts: 223
Joined: Mon Nov 09, 2009 10:56 pm
Location: Denver

Postby grzegorz.zajac » Tue Dec 08, 2009 7:50 pm


By using addHeaderView() you just attach a custom view to the beginning of the list. If you then scroll the list the header will be scrolled too (this is what I remember when I was using this approach some time ago - but try it once again as I might be wrong :D )

I would rather use one of the two methods (2nd is my favorite one):

1) the LinearLayout oriented vertically, with the TextView or Button as the first item and the ListView as the second one.
2) use custom View as the application title - take a look for requestWindowFeature() function and the example at:

Posts: 39
Joined: Wed Feb 18, 2009 8:37 pm
Location: Krakow/Poland


Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 3 guests