Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RecyclerView stackFromBottom

I just implemented the new RecyclerView. I want to use it do display user's messages(sms).

I read on official documentation that RecyclerView is a new and improved ListView (something like that) and we should use it for better performance.

Everything went great until I wanted to display a user's conversation and I want the messages to be displayed starting from the bottom. In a ListView I would normally use android:stackFromBottom="true" but when I tried this in the RecyclerView it didn't work (even if didn't receive any error).

Does anyone know how to make the RecyclerView's items to be stacked from bottom? Thank you.

like image 657
stanga bogdan Avatar asked Dec 18 '14 21:12

stanga bogdan


2 Answers

Making it a little explicit:

   final LinearLayoutManager layoutManager = new LinearLayoutManager(mActivity);
   layoutManager.setStackFromEnd(true);
   recyclerView.setLayoutManager(layoutManager);
like image 116
Lars Avatar answered Nov 17 '22 04:11

Lars


Thanks to tyczj's comment I figured it out. In RecyclerView instead of stackFromBottom you have to use stackFromEnd https://developer.android.com/reference/android/support/v7/widget/LinearLayoutManager.html#setStackFromEnd(boolean)

like image 9
stanga bogdan Avatar answered Nov 17 '22 04:11

stanga bogdan