Skip to content

onLayoutChildren resets the current scroll offset and changes the scroll position #83

@Maxr1998

Description

@Maxr1998
  • Device: Samsung Z Fold 4
  • OS Version: Android 13, OneUI 5.1
  • Project Version: latest git

🐛 Describe

When onLayoutChildren is called at a non-zero scroll offset, e.g., by a call to Adapter.notifyItemRangeChanged(0, size), the scroll offset will be reset to zero.

🐌 Steps to reproduce

  1. Have a list of elements and scroll a bit to make a view partially visible.
  2. Call notifyItemRangeChanged(0, size) on the adapter, and observe onLayoutChildren being called again.
  3. The current scroll position will be reset, to a random (near?) item which is aligned with the RecyclerView again – the scroll offset of the first visible view is zero.

🦋 Expected behavior

The scroll position should be kept. Compare RecyclerView's built-in LinearLayoutManager, which shows this behavior.

🐝 Requested assignment

I would love to fix this myself, but with the complexity of the RecyclerView library and a lack of knowledge and time on my side, I won't be able to fix this myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions