For the More Curious: Detecting Gestures

Another option for handling touch events is to use a GestureDetectorCompat object (developer.android.com/​reference/​androidx/​core/​view/​GestureDetectorCompat). Instead of adding logic to detect events like a swipe or a fling, the GestureDetectorCompat has listeners that do the heavy lifting and notify you when a particular event occurs.

Many cases do not require the full control provided by overriding the onTouch function, so using the GestureDetectorCompat instead is a great choice.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset