fun ViewPager2.reduceDragSensitivity() {
val recyclerViewField = ViewPager2::class.java.getDeclaredField("mRecyclerView")
recyclerViewField.isAccessible = true
val recyclerView = recyclerViewField.get(this) as RecyclerView
val touchSlopField = RecyclerView::class.java.getDeclaredField("mTouchSlop")
touchSlopField.isAccessible = true
val touchSlop = touchSlopField.get(recyclerView) as Int
touchSlopField.set(recyclerView, touchSlop * 2) // "2" was obtained experimentally
}
哈哈,为什么非得用ViewPager2呢?
mark
回答得有点晚了哈
解决方案如下:
Kotlin 代码
Java 代码
参考链接:https://stackoverflow.com/questions/60660570/viewpager2-reduce-sensitivity-of-horizontal-scrolling
我也在找这个, 大佬解决了 通知一声呢