Search code examples
androidandroid-recyclerviewlinearlayoutmanagerpagersnaphelper

Nudge a paged recyclerview to hint at next page without switching


I'm using a horizontal recyclerview with a LinearLayoutManager and a PagerSnapHelper and each viewholder/page is fullscreen and snaps to the window so only one page is viewable once settled. Like most fullscreen swipeable tabs.

When inserting a new page AFTER the current page, I want to temporarily show/hint at it's presence without snapping/scrolling to it i.e. so the user knows they opened a new page and it's there if they want to view it without forcing them to actually view it.

So it would be the same effect if you were to start dragging your finger a tiny bit to expose the next page before releasing and letting it snap back to the starting page.

How can I do this? Thanks


Solution

  • recyclerView.smoothScrollBy(nudgeDistanceInPx, 0);
    

    This will smooth scroll to show the next page a little before the PagerSnapHelper kicks in and returns it to it's starting position