7

I have a ViewHolder that contains another RecyclerView. This type of the ViewHolder gets reused multiple times.

Since the ViewHolder is shared between different items, the scroll position of the RecyclerView is also shared between items. Eg, You scroll to the end of the first item, the fifth item's RecyclerView also gets scrolled to the very end, because the view is reused.

I'm trying to solve this by mapping 1 ViewHolder to 1 item.

I've tried to set an itemId for the item, call RecyclerView.ViewHolder#setIsRecyclable(false), and extend/set RecyclerView.getRecycledViewPool().setMaxRecycledViews() as mentioned in this answer

After I scroll down and scroll back up (The ViewHolder gets recycled), the scroll position of the inner RecyclerView is reset to the first item.

Community
  • 1
  • 1
esong
  • 260
  • 1
  • 11
  • The only solution I found is to store the LayoutManager state(onSaveInstanceState) to the model during onRecycle event, and try to restore(onRestoreInstanceState) the layout manager state in bind method. – esong Jan 22 '19 at 21:42

0 Answers0