airbnb / epoxy

Epoxy is an Android library for building complex screens in a RecyclerView
https://goo.gl/eIK82p
Apache License 2.0
8.47k stars 731 forks source link

Scroll position reset after `onDetachedFromWindow` and `recycleChildrenOnDetach == true` #1242

Open eygraber opened 2 years ago

eygraber commented 2 years ago

Following the wiki guidance on avoiding memory leak I have been setting LayoutManager.recycleChildrenOnDetach = true for all of my EpoxyRecyclerViews.

I'm using one in a ViewPager now, and when scrolling away from the EpoxyRecyclerView and then coming back to it, my scroll position is lost. If I don't set recycleChildrenOnDetach = true then my scroll position is not lost.

Is there any way around this?

elihart commented 2 years ago

i'm guessing you're not saving and restoring view state to your recyclerview correctly, since that is what controls scroll position