allow making Myscrollview not scrollable
This commit is contained in:
parent
dcbcaaf789
commit
6734f60dcd
1 changed files with 19 additions and 0 deletions
|
@ -2,9 +2,12 @@ package com.simplemobiletools.calendar.pro.views
|
|||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import android.widget.ScrollView
|
||||
|
||||
class MyScrollView : ScrollView {
|
||||
var isScrollable = true
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
|
||||
|
@ -22,6 +25,22 @@ class MyScrollView : ScrollView {
|
|||
scrollViewListener?.onScrollChanged(this, x, y, oldx, oldy)
|
||||
}
|
||||
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
return if (isScrollable) {
|
||||
super.onTouchEvent(event)
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
|
||||
return if (isScrollable) {
|
||||
super.onInterceptTouchEvent(event)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
interface ScrollViewListener {
|
||||
fun onScrollChanged(scrollView: MyScrollView, x: Int, y: Int, oldx: Int, oldy: Int)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue