How to add a scrollable header to a gridview in android?
Asked Answered
M

1

8

Im attempting to add a scrollable header to a gridview layout in android, Ive tried about everything I could find on the web but I cant get it to work, this type of layout appears in a number of popular apps such as facebook and instagram but Im not able to find any such sample code that would give me an Idea as to how to actually do it, anyone know how this can be achieved? adding the gridview to a scrollview doesnt work either, below are some photos that illustrate what Im trying to achieve.

This is before the scroll:

before scroll

This is after the scroll: after scroll

Masefield answered 20/10, 2012 at 21:27 Comment(1)
You might find github.com/emilsjolander/StickyListHeaders usefulBohner
S
14

Do not use a gridview. Instead use a listview which has this header functionality. And in the getView() method of your adapter you will have to return a list item divided into the number of columns you want.

Sapphism answered 22/10, 2012 at 10:56 Comment(3)
Thanks Emil!That's what I figured may be the only solutionMasefield
Is there a reason not to use TableLayout for this purpose?Submaxillary
@Tom grid and list views have built in a system of recycling views so they are much more efficient in memory, specially when showing lists full of imagesAdolfoadolph

© 2022 - 2024 — McMap. All rights reserved.