RecyclerView does not change position to bottom element when adding new element

I am creating a chat application and using RecyclerView.

This is the stack below.

When new messages appear. then we need to manually scroll this position.

It does not automatically change position like WhatsApp when new messages appear.

I used to use a ListView in which it works correctly.

+5
source share
2 answers

Try it,

recyclerView.scrollToPosition(messages.size()-1); 

or

 recyclerView.setStackFromEnd(true) 
+3
source

You can use the RecyclerView.scrollToPosition() function. Something like mRecyclerView.scrollToLastPosition(mAdapter.getCount()-1)

+3
source

All Articles