2

I want know how to add header like Play Store with gridview in horizontal mode enter image description here

  • the are plugins to help you do that -- http://tonicartos.github.io/StickyGridHeaders/ -- or by code -- http://stackoverflow.com/questions/13217386/add-a-header-to-a-gridview-android – Tasos Feb 22 '16 at 04:03
  • If the below answer solves your problem, you should accept it, so that it makes it easy for the coming users to find solution to the problem. – Yash Feb 22 '16 at 08:32
  • This would seem to be the way to go today ... https://tonicartos.github.io/SuperSLiM/ – Fattie Nov 29 '16 at 16:32
  • or possibly the older https://github.com/DWorkS/AStickyHeader – Fattie Nov 29 '16 at 16:34

1 Answers1

0

The horiontal gridview can be achieved by Recycler view.

For adding the heading, put a textview and the recycler view in a linear layout (with vertical orientation of course), something like this :

<LinearLayout orientation="vertical" ..... >
    <Textview ...... />
    <RecyclerView .... />
</LinearLayout>

And for achiving the horizontal view in recycler view, set the layoutmanager in java as :

recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));

Note that, wrap_content is not yet supported by RecyclerView. To overcome that, you'd have to either

1) set minHeight/minWidth attribute.

2) use a custom layout manager

N J
  • 27,217
  • 13
  • 76
  • 96
Yash
  • 5,225
  • 4
  • 32
  • 65