Here is I have I have tried so far
LinearLayoutManager layoutManager =
new GridLayoutManager(getActivity(), 2, GridLayoutManager.HORIZONTAL, false);
but It showed 2 rows instead of two columns.
How can I show two items with horizontal scroll with recycler view?
To be able to scroll through a vertical list of items that is longer than the screen, you need to add a vertical scrollbar. Inside RecyclerView , add an android:scrollbars attribute set to vertical .
This wear-specific implementation of LinearLayoutManager provides basic offsetting logic for updating child layout. A RecyclerView. LayoutManager implementation which provides similar functionality to android. widget. ListView .
Alright here is a funda,
When you are using GridLayoutManager.HORIZONTAL
, second parameter will be considered as number of rows
while, when you write GridLayoutManager.VERTICAL
second parameter will be considered as number of columns
Also, this
LinearLayoutManager layoutManager =
new GridLayoutManager(getActivity(), 2, GridLayoutManager.HORIZONTAL, false);
supposed to be,
GridLayoutManager layoutManager =
new GridLayoutManager(getActivity(), 2, GridLayoutManager.HORIZONTAL, false);
in above code, 2 is considered as number of rows to be generated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With