0

I am trying to implement messenger, so I used for that RecyclerView with stackFromEnd = true option. And I faced a problem, when I insert new item to the list my recycler view scrolls up to one item, instead of staying at last. I suppose it is cause of stackFromEnd parameter. Can someone explain little bit what is happening with my RecyclerView? By the way I used DiffUtil in order to update items in list, but it works ok, cause my edit message function works properly. My adding functions looks like this

fun addNewMessage(message: ChatMessageUi) {

    messages.add(message)
    submitList(messages)
}

Here as you can see I used submitList() method cause in all articles that I read about DiffUtil, when mention insertion of new item, they advise to use submitList() function, but it did not help me.

Asset Bekbossynov
  • 1,633
  • 3
  • 13
  • 25
  • [This](https://stackoverflow.com/questions/43458146/diffutil-in-recycleview-making-it-autoscroll-if-a-new-item-is-added) can help you – Zain Nov 03 '21 at 06:31
  • @Zain Tried this one, still RecyclerView scrolls up almost to one item. Moreover I pointed out that, when I delete message, it scrolls up to (let's say) x, next delete scrolls up to 2x, and so on, `recyclerView.smoothScrollToPosition(position)` worked only for new added message, but for other edit/delete operations still problem is occurring – Asset Bekbossynov Nov 03 '21 at 12:38

0 Answers0