class LoopPagerSnapHelper : PagerSnapHelper() {
override fun findTargetSnapPosition(layoutManager: RecyclerView.LayoutManager, velocityX: Int, velocityY: Int): Int {
val position = super.findTargetSnapPosition(layoutManager, velocityX, velocityY)
return position % layoutManager.itemCount
}
}
目前找到一个解决方案,可以通过自定义 SnapHelper 解决