Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RecyclerView not changing position to bottom element when new item added

I am creating the chat application and using the RecyclerView.

It is stack from bottom.

When new messages are coming. then we need to manually scroll to that position.

It not automatically changing the position like WhatsApp does when new messages received.

Earlier i am using ListView in which its working properly.

like image 686
Jarvis Avatar asked Jun 15 '16 10:06

Jarvis


2 Answers

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

like image 64
Vanya Sakharovskiy Avatar answered Nov 18 '22 06:11

Vanya Sakharovskiy


Try this,

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

or

recyclerView.setStackFromEnd(true) 
like image 4
Er. Kaushik Kajavadara Avatar answered Nov 18 '22 08:11

Er. Kaushik Kajavadara