Reputation: 668
I am using multiple view type inside the recyclerview. In which one of the view type is recyclerview of linear layoutmanager with horizontal orientation. I loaded all view type inside the parent recyclerview. When I change the some item in horizonatal recyclerview item of position 10 and update by adapter?.notifyItemChanged(10)
, the horizonatal recyclerview jump to first position 0. And it creates a bad user experience.
Also I used android:descendantFocusability="blocksDescendants"
and setHasFixedSize(true)
in parent and child Recyclerview not does not works. Is there is any way to solve my problem. And also attached image for reference
Here position 1 is horizonal recyclerview
Upvotes: 1
Views: 37
Reputation: 12953
You could save the RecyclerView
's layout instance and restore post notifying adapter
, this will restore layout manager properties like scroll position
val savedInstance = recyclerView.layoutManager?.onSaveInstanceState()
adapter?.notifyItemChanged(10)
recyclerView.layoutManager?.onRestoreInstanceState(savedInstance)
Upvotes: 1