Reputation: 363
I am loading Pictures and Strings into a Recyclerview. I once had it that the setStackfrombottom was working. But now it is not. I dont know why. This is my Code :
MessageAdapter messageAdapter = new MessageAdapter(chatsList, Chat_Room.this);
LinearLayoutManager manager = new LinearLayoutManager(getApplicationContext());
manager.setStackFromEnd(true);
recyclerView.setLayoutManager(manager);
recyclerView.setItemViewCacheSize(30);
recyclerView.setDrawingCacheEnabled(true);
recyclerView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(messageAdapter);
The ChatsList is a List, which contains a constructor of Strings. What else can I try?
EDIT
It was not working because I used Picasso. After I changed it to Glide it was working better and more smooth. And after I set the Adapter I did this:
recyclerView.scrollToPosition(messageAdapter.getItemCount()-1);
To scroll to the last position. And now it is working fine.
Upvotes: 0
Views: 4795
Reputation: 29
You can use in XML
app:reverseLayout="true"
Or you can use in Code side (Kotlin)
val manager = LinearLayoutManager(context)
manager.reverseLayout = true
Upvotes: 0
Reputation: 363
I was recieving the Data from Firebase. So it was already in the right order. After I set the Adapter, I scrolled to the last postition:
recyclerView.scrollToPosition(messageAdapter.getItemCount()-1);
So it scrolls now to the last position. (The -1 because the Adapter starts counting at 0 )
Upvotes: 1