Open imrankst1221 opened 4 years ago
@imrankst1221 This is an issue in ViewPager2 reported at https://issuetracker.google.com/issues/123006042
To fix this, you should extend the ViewPager2 like this:
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*8) // "8" was obtained experimentally
}
and call reduceDragSensitivity. So the viewpager2 will look like this:
view_pager.reduceDragSensitivity()
mark
MainActivity
Fragment