Home » Android » How to add a scrollable header to a gridview in android?

How to add a scrollable header to a gridview in android?

Posted by: admin June 15, 2020 Leave a comment

Questions:

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

How to&Answers:

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.