I am trying to implement a ViewPager-like behavior for a horizontal RecyclerView
. The data from the adapter should inflate and bind as normal, but the navigation through the Recycler
should be handled differently. When the user swipes (or attempts to scroll), I move the Recycler
one item in that direction, sticking it to the left side.
I already have all the item transition logic. I am using a custom LayoutManager
, which overrides onSmoothScrollToPosition()
with a custom LinearSmoothScroller()
which does the item to-the-left sticking.
The question is - how can I override the scrolling behavior of the RecyclerView
to intercept the swipes and handle them myself? I tried disabling scrolling in the LayoutManager
and then intercepting the gesture in an onTouchListener
, but this does not seem to work. Does the RecyclerView
framework have a clean way to handle this?