If I swipe left to right or right to left, then I swipe up or down without releasing finger swiping up or down occurred on Scroll Gesture. But I don't want to occur this. I want if am swiping horizontally only horizontal swiping should work not vertical without release finger. I don't know how doing that in android studio, If anyone can help, please help me, thanks in advance.
I have already tried, but can't solve the above problem.
override fun onScroll(event: MotionEvent?, event1: MotionEvent?, distanceX: Float, distanceY: Float): Boolean {
val sWidth = Resources.getSystem().displayMetrics.widthPixels
val sHeight = Resources.getSystem().displayMetrics.heightPixels
val border = 100 * Resources.getSystem().displayMetrics.density.toInt()
if(event!!.x < border || event.y < border || event.x > sWidth - border || event.y > sHeight - border)
return false
if(abs(distanceX) < abs(distanceY)){
if(event.x < sWidth/2){
//brightness
// left side up and down
}
else{
//volume
// right side up and down
}if (distanceY > distanceX){
If (distance Y > 0){
// left to right swipe
}else{
// right to left swipe
}
}
return true
}
When I swipe up and down. Left or Right swipe also occur.