0

I am implementing chat application like whatsapp. I do have log list of messages that I will put in recycle view. Problem is that I am unable to reach at bottom of recycle view when it first time load all messages like whatsapp. I have tired this so far.

    layoutManager = new LinearLayoutManager(requireActivity());
    layoutManager.setReverseLayout(true);
    chatMessageFragmentBinding.recycleViewMessageList.setLayoutManager(layoutManager);
    chatMessageFragmentBinding.recycleViewMessageList.addOnScrollListener(onScrollListener);
    chatMessageFragmentBinding.recycleViewMessageList.setAdapter(chatMessageAdapter);


  
HemangNirmal
  • 621
  • 1
  • 8
  • 24
  • Does this answer your question? [How to scroll to the bottom of a RecyclerView? scrollToPosition doesn't work](https://stackoverflow.com/questions/26580723/how-to-scroll-to-the-bottom-of-a-recyclerview-scrolltoposition-doesnt-work) – Bruno Jul 08 '20 at 08:46
  • 1
    did you try set layoutManager.setStackFromEnd(true)? – Công Hải Jul 08 '20 at 08:48
  • yes I tried that also but not worked – HemangNirmal Jul 08 '20 at 08:54

1 Answers1

0

You will have to get the size of the list which you are setting into the recycler view first, the you can smooth scroll to size -1.

rv.smoothScrollToPosition(mMessagesList.size()-1);

Sirsha
  • 1
  • 1