Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Recycler View show rows from bottom

Tags:

android

I saw somewhere method to make RecyclerView show ViewHolders from bottom to top. Now, i can't find it anywhere (after half of hour going through RecyclerView, RecyclerAdapter, LayoutManager...).

like image 798
JoKr Avatar asked Apr 06 '15 16:04

JoKr


People also ask

How can show all items in RecyclerView without scrolling?

It's pretty simple, simply set the RecyclerView 's height to wrap_content . That's right.


2 Answers

Is it LinearLayoutManager.setStackFromEnd(true) you are looking for?

Edit

Turns out LinearLayoutManager.setReverseLayout(true) does the trick. Either way, the reader may want to try each of the methods and the combination of both to get the needed effect.

like image 137
AndroidEx Avatar answered Sep 21 '22 23:09

AndroidEx


Here is the solution in Kotlin

val llm = LinearLayoutManager(this) llm.stackFromEnd = true     // items gravity sticks to bottom llm.reverseLayout = false   // item list sorting (new messages start from the bottom)  rv_chat_history.layoutManager = llm 

Or if you like the apply method:

recycler.apply {      layoutManager = LinearLayoutManager(this).apply {          stackFromEnd = true         reverseLayout = false     } } 
like image 25
AbhinayMe Avatar answered Sep 21 '22 23:09

AbhinayMe