public class PagerSnapHelper
extends SnapHelper

   ↳ androidx.recyclerview.widget.RecyclerView.OnFlingListener
     ↳ androidx.recyclerview.widget.SnapHelper
       ↳ androidx.recyclerview.widget.PagerSnapHelper

Implementation of the SnapHelper supporting pager style snapping in either vertical or horizontal orientation.

PagerSnapHelper can help achieve a similar behavior to ViewPager. Set both RecyclerView and the items of the RecyclerView.Adapter to have ViewGroup.LayoutParams.MATCH_PARENT height and width and then attach PagerSnapHelper to the RecyclerView using SnapHelper.attachToRecyclerView(RecyclerView).


Public constructors


Public methods

int[] calculateDistanceToFinalSnap(RecyclerView.LayoutManager layoutManager, View targetView)

Override this method to snap to a particular point within the target view or the container view on any axis.

View findSnapView(RecyclerView.LayoutManager layoutManager)

Override this method to provide a particular target view for snapping.

int findTargetSnapPosition(RecyclerView.LayoutManager layoutManager, int velocityX, int velocityY)

Override to provide a particular adapter target position for snapping.

Protected methods

RecyclerView.SmoothScroller createScroller(RecyclerView.LayoutManager layoutManager)

Creates a scroller to be used in the snapping implementation.

Inherited methods