Snap RecyclerView: Center Target Child View or ViewPager Full View Display

May 4, 2019
LinearSnapHelper, PagerSnapHelper


The implementation will snap the center of the target child view to the center of the attached RecyclerView

val snapHelper = LinearSnapHelper()


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).

val snapHelper = PagerSnapHelper()
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.