2

My code looks like this, I am setting my layoutManager in onAttachedToRecyclerView of my Adapter.

class ChatsAdapter(messages:List<ChatMessage>): RecyclerView.Adapter<ViewHolder>{

init {
        setHasStableIds(true)
    }

    override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
            super.onAttachedToRecyclerView(recyclerView)    

        recyclerView.layoutManager = LinearLayoutManager(recyclerView.context, RecyclerView.VERTICAL, true).apply {
                    stackFromEnd = true
                }
        recyclerView.setHasFixedSize(true)
    }

As you can see reversed = true as well as stackFromEnd = true.

But when I add item to the 0th position which is at the bottom of the recyclerView. It is animated from the very top of RecyclerView to the very bottom. It should rather animate from below RecyclerView. All of these item has unique Id's as well.

Also weird thing is, all items are in correct order but they are stacked to top. I want them to stack to the bottom.

Rishabh876
  • 1,971
  • 1
  • 14
  • 31

0 Answers0