I am new to Android. Here, I want to implement Swipe Gesture to navigate between Activities. I have googled it and found different answers in different sites. But I could not get the exact point.
By reading all of them I got that we need to implement onTouchEvent()
and onFlingEvent()
.
Are these functions enough to implement the Swipe action? Please specify on How to proceed step wise to implement swipe gesture.
I am sorry if I asked you a very simple question as I have asked this question after a long long try of many code snippets.
Can any one please clear my doubt?
Speaking of this, Android's modern gesture navigation is only available on Android 10 and later. If you're running Android 9 Pie, you'll need to select Swipe up on Home button instead of System navigation in the Gestures menu.
onTouchEvent
is enough. What you want to do is:
VelocityTracker
and feed it the
touch results from the view.You'll likely have to play with the threshold a bit, otherwise a sloppy tap could be mistaken for a swipe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With