Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RecyclerView - Reverse Order

Tags:

android

I am using a recycler view in reverse order to display a chat History.
If there is only one message in a chat, it display the message in the bottom (like telegram). But i need to display it from the top.
I am stuck in this for a day. Can anyone please give me a suggestion to display the message from top in recyclerview reverse order (like whatsapp).

like image 937
Saravanakumar Avatar asked Sep 12 '17 05:09

Saravanakumar


People also ask

How do I start the recycler view from the bottom?

setReverseLayout(true) does the trick.


2 Answers

You can also use this:

LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); linearLayoutManager.setReverseLayout(true); linearLayoutManager.setStackFromEnd(true); myRecyclerView.setLayoutManager(linearLayoutManager); 
like image 166
Kun Szabi Avatar answered Sep 28 '22 12:09

Kun Szabi


I faced same problem some day's ago. Whatever I solve this by this way.

<android.support.v7.widget.RecyclerView         android:id="@+id/reyclerview_message_list"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:scrollbars="vertical"         app:stackFromEnd="true"         app:reverseLayout="true"/> 
like image 23
Tanvir Durlove Avatar answered Sep 28 '22 12:09

Tanvir Durlove