Xiasm / LooperLayoutManager

实现无限循环的RecyclerView
108 stars 55 forks source link

结合PagerSnapHelper使用的时候,会出现一次滑动多页的情况 #2

Open getglory opened 5 years ago

YuYongzhi commented 5 years ago

目前找到一个解决方案,可以通过自定义 SnapHelper 解决

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
    }
}
chaoshenzhilu commented 4 years ago

我用 LinearSnapHelper的时候 滑动一下 然后就没有然后了 根本停不下来