Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Horizontal RecyclerView scroll Direction

I made a Horizontal RecyclerView and it works fine(thanks to this) but the direction of scroll and data are expand from left to right; then How can I change the RecyclerView scroll direction like in the picture below?

enter image description here

My Code:

StaggeredGridLayoutManager staggeredGridLayoutManager =                 new StaggeredGridLayoutManager(                         2, //The number of Columns in the grid                         LinearLayoutManager.HORIZONTAL); 
like image 437
Hamid Goodarzi Avatar asked Jun 09 '16 18:06

Hamid Goodarzi


People also ask

What is LinearLayoutManager Android?

LayoutManager implementations that lays out items in a grid. WearableLinearLayoutManager. This wear-specific implementation of LinearLayoutManager provides basic offsetting logic for updating child layout. A RecyclerView. LayoutManager implementation which provides similar functionality to ListView .

How do you make a page indicator for horizontal RecyclerView?

You can add an indicator by using RecyclerView. ItemDecoration. Just draw some lines or circles at the bottom and use layoutManager. findFirstVisibleItemPosition() to get the current active item.


1 Answers

Assuming you use LinearLayoutManager in your RecyclerView, then you can pass true as third argument in the LinearLayoutManager constructor.

For example:

mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, true)); 

If you are using the StaggeredGridLayoutManager, then you can use the setReverseLayout method it provides.

like image 120
gmetal Avatar answered Sep 19 '22 11:09

gmetal