Photo by Stefan Kunz on Unsplash

Android Notes 46: How to reverse RecyclerView by adding items [UPDATED]

Kuray Ogun
FreakyCoder Software Blog

--

Updated: April 13, 2020

To reverse our RecyclerView, then we totally need this code segment. It does not require any modification or any special library. It’s so simple to work on LinearLayoutManager .

Code:

LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
mLayoutManager.setReverseLayout(true);
mLayoutManager.setStackFromEnd(true);
// Set the layout manager to your recyclerview
recyclerView.setLayoutManager(mLayoutManager);

Gist :

We need to create a LinearLayoutManager object and use setReverseLayout(true)and setStackFromEnd(true) methods to reverse and add an item at the end.

If you have a question, ask me :)

--

--