Losing nested scroll position when scrolling parent
See original GitHub issueHello!
I have a vertical list composed of multiple nested horizontal lists. If I scroll my horizontal list and then scroll vertically my list, I sometime lost the scroll position of my nested horizontal list.
Losing nested position demo:
1- scrolling “A voir aussi” to Calls as first fully displayed item
2- scrolling “Sous couverture” to Strike Back as first fully displayed item
3- scroll down
4- scroll up: “A voir aussi” scrolling position is ok but “Sous couverture” isn’t, it display as first item “Killing Eve”
Here is my code: https://github.com/loutry/EpoxySample/commits/lost-nesting-position-on-rebind
I’m using EpoxyRecyclerView
everywhere and I enable saveViewState
.
I also followed the discussions https://github.com/airbnb/epoxy/issues/561 but I didn’t successfully fix my problem.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Your
RowGroupView
is aLinearLayout
and Epoxy is saving its state only (withsaveViewState = true
) . To restore scroll position you need to manually save/restore the state of the innerEpoxyRecyclerView
from yourRowGroupView
.As a quick fix try something like :
Hi again! I end up fixing my problem by relying on
ViewGroup
andViewStub
as state in the documentation: https://github.com/airbnb/epoxy/wiki/Grouping-Models.Here is the updated branch on the sample: https://github.com/loutry/EpoxySample/tree/viewstub
Our custom layout manager was indeed not compliant regarding state restoration but nothing that we can’t manage on or own 😃
Thanks a lot for your guidance and time!