I set my recyclerView's layoutManager like this:
recyclerView.layoutManager = LinearLayoutManager(context, HORIZONTAL, true)
The last parameter sets the reverseLayout
to true
which means it will be loaded from right to left. I need this because I implement a sort of calendar where the last date is current date but you can scroll into the past infinitely.
The problem is that when in my adapter I call notifyItemChanged
or notifyDataSetChanged
the list scrolls a few pixels to the right. This doesn't happen with reverseLayout=false
.
It also only happens while the size of the RecyclerView is MATCH_PARENT
, when I set it manually to whatever dp, the problem is gone.
Any ideas what happens and how to cope with it?
Setting RecyclerView dimensions programmatically worked for me.
In kotlin -
xml -
Where I want recyclerView between bottomLayout and appBarLayout and constraintLayout is root layout.