question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What is the proper way to save the scroll position in an EpoxyRecyclerView?

See original GitHub issue

When I use the back button to return to my Fragment (which is only a vertical EpoxyRecyclerView using MvRx) it starts at the top of the list instead of the screen. This is probably annoying for users who click on a photo, see the full screen image, and then end up at the top of the screen when hitting back. Is this something Android should be doing automatically? Should I be storing the scroll position in onSavedInstanceState? Or does Epoxy have some other solution?

I know that I can set saveViewState on Models, but I don’t see how this would help the RecyclerView resume at the previous scroll position.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
guozhiqiang123commented, Mar 27, 2022

I have the same problem ! I use carousel within a vertical RecyclerView+Navigation,but carousel not saved the position.

0reactions
xuexixuexijpgcommented, Jun 15, 2022

I am also having this exact same issue where nested recyclerview contains horizontal carousel and whenever I navigate to other page and back, the carousels position is not retained - I have overridden shouldSaveViewState and I have tried to initialize controller in onViewCreated and in onCreate without good results

This is indeed the case. I did the same thing. Although my original method kept the scroll position, the adapter leaked. Now if I use this, it is no problem to empty the adapter when I leave the window, but the original scroll state is gone. I don’t know how to solve it, maybe I can rewrite the navigation component to not destroy the view when navigating?Just overlay the view. This is the BaseEpoxyFragment I wrote while practicing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to save and restore scrolling position of the RecyclerView ...
I am using a linearlayout for my recyclerview and I've placed my code (myAdapter.setStateRestorationPolicy(RecyclerView.Adapter.
Read more >
Saving Scroll Positions of Nested RecyclerViews - Medium
The idea behind this solution is that we will save the current scroll index of each horizontal carousel in some data structure before...
Read more >
Epoxy for Android - Airbnb Engineering & Data Science
Additionally, Epoxy adds support for saving view state and automatic diffing ... to specify what layout your model uses and how to bind...
Read more >
How to save RecyclerView's scroll position using ... - YouTube
Android : How to save RecyclerView's scroll position using RecyclerView.State?
Read more >
SAVED INSTANCE STATE AND RECYCLERVIEW SCROLL ...
This video wraps up the movie app with the use of saved instance state to persist the popular and most rated movie with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found