I want know how to add header like Play Store with gridview in horizontal mode
Asked
Active
Viewed 830 times
2
-
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 Answers
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
-
Hey for example, if the
before an RecyclerView is bigger, i can use the ScrollView without error "scrollview can host only one direct child" – Helio Soares Junior Feb 22 '16 at 22:37 -
1@HelioSoaresJunior : I didn't get your question. Can you rephrase it more clearly? – Yash Feb 23 '16 at 05:18
-
For example, if I have more views below of RecyclerView, it will create the scroll automatically? (Views off the list) – Helio Soares Junior Feb 23 '16 at 20:29
-
1No, it won't. If your content needs scrolling, you should place everything above inside a scrollview tag. – Yash Feb 24 '16 at 05:15
-
thanks, i will try, when I used the listview I can not use another scroll – Helio Soares Junior Feb 24 '16 at 18:44