I was implementing Different Gestures in Android. I want to know what methods do I use for implementing different gestures like "Tap,Double Tap,Hold,Drag,Flick,Swipe" etc
Asked
Active
Viewed 194 times
-1
-
1Basically `#setOnTouchListener()` on View... – ADM Jun 19 '19 at 10:45
-
Did you find my answer helpful ? – Jasurbek Jun 25 '19 at 19:18
1 Answers
0
Here is the Kotlin example that I have implemented
private val gestureDetector by lazy {
GestureDetector(applicationContext, object : GestureDetector.SimpleOnGestureListener() {
override fun onLongPress(e: MotionEvent?) {
//Your action onLongPress
super.onLongPress(e)
}
// here you can implement other function like onDoubleTap ....
})
}
To use this variable you should use #setOnTouchListener()
as @ADM suggested
your_view.setOnTouchListener { _, event ->
gestureDetector.onTouchEvent(event)
return@setOnTouchListener true
}
Hope it helps, let me know if you want this code in Java

Jasurbek
- 2,946
- 3
- 20
- 37