Skip to content

Instantly share code, notes, and snippets.

@yasukotelin
Last active October 9, 2020 16:19
Show Gist options
  • Save yasukotelin/ae1978683e3a756122cfe6efae925dea to your computer and use it in GitHub Desktop.
Save yasukotelin/ae1978683e3a756122cfe6efae925dea to your computer and use it in GitHub Desktop.
class NoSwipeViewPager(context: Context, attrs: AttributeSet) : ViewPager(context, attrs) {
@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent): Boolean {
// disable swipe
return false
}
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
// disable swipe
return false
}
override fun setCurrentItem(item: Int, smoothScroll: Boolean) {
// disable swipe animation
super.setCurrentItem(item, false)
}
override fun setCurrentItem(item: Int) {
// disable swipe animation
super.setCurrentItem(item, false)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment