[PagingWithNetworkSample] Scroll position is offset when loading completes
See original GitHub issueThis is an issue I’ve seen in my own project and so I checked out how it is done here and I’m seeing the same bug. When loading the data for the first time using the DB + Network
option, the scroll bar is not at the top when loading finishes, but partway down the screen. How can we keep the scroll position stuck to the top while loading? With a large dataset this is more obvious and it’s not a great experience.
See recording here: https://drive.google.com/open?id=1OwT87Gj5BeGz-ld_fIyQaIJvfz_49Tut
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Android Paging 3 - experiencing flickers, glitches or jumps in ...
By default, Room's PagingSource picks an index based on last bound position and offsets based on pageSize . In order for refresh to...
Read more >Wrong scroll position if page is loaded when ... - Issue Tracker
Discovered a bug where the scroll position is not preserved when page data is loaded outside visible area while only the placeholders are...
Read more >Source Code for PagedList.java - AndroidX Tech
<p> * PagedList can present data for an unbounded, infinite scrolling list, ... are * loaded or dropped) and fast-scrolling to any position,...
Read more >error: rendered more hooks than during the previous render.
Examine which components are taking more time to load. ... function that will be executed once setState is completed and the component is...
Read more >Can you properly restore the RecyclerView scroll position ...
When state is saved, layout manager saves whatever necessary (e.g. for `LinearLayoutManager`, it is the top item's position + offset from anchor ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the fix @dlam! It turns out the issue in my app was because the app’s sort order was different than the sort order of the data from the network. Thanks to you and the guys at dev summit for helping me resolve this bug 🙌 🙌
So it seems the issue is that RecyclerView is using the loading spinner as an anchor during initial load since Paging gives it an initial empty list + spinner, while it’s waiting for the initialLoad to complete, which then completes with initial page + spinner.
There’s a workaround here #751 - thanks for reporting the issue!
Another way to fix this would be to actually send a AsyncDiffer update to remove the spinner before loading in the initial page or to prevent the differ from ever successfully comparing the spinner.