Created
December 4, 2018 10:10
-
-
Save wbinarytree/7bcc93b59ee8cc117e80e4557dae33e2 to your computer and use it in GitHub Desktop.
ViewPager that can disable scroll.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package fr.airweb.dood.widgets | |
| import android.annotation.SuppressLint | |
| import android.content.Context | |
| import android.support.v4.view.ViewPager | |
| import android.util.AttributeSet | |
| import android.view.MotionEvent | |
| class NoScrollViewPager : ViewPager { | |
| private var isPagingEnabled = true | |
| constructor(context: Context) : super(context) | |
| constructor(context: Context, attrs: AttributeSet) : super(context, attrs) | |
| @SuppressLint("ClickableViewAccessibility") | |
| override fun onTouchEvent(event: MotionEvent): Boolean { | |
| return this.isPagingEnabled && super.onTouchEvent(event) | |
| } | |
| override fun onInterceptTouchEvent(event: MotionEvent): Boolean { | |
| return this.isPagingEnabled && super.onInterceptTouchEvent(event) | |
| } | |
| fun setPagingEnabled(b: Boolean) { | |
| this.isPagingEnabled = b | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment