Responding to scroll gestures
There are many more ways for a user to interact with the device when using a single finger. These interactions include scrolling, flinging, and various kinds of tapping.
How to do it…
To receive the events from the gesture detector, we must implement the nested interface in the GestureDetector
type and pass the instance to the gesture detector:
- For most gestures, we implement the
IOnGestureListener
interface. As we are going to implement scrolling and flicking, we returntrue
for theOnDown()
,OnFling()
, andOnScroll()
methods. Because we are not concerned with the screen taps, we returnfalse
for theOnSingleTapUp()
method:public class MyView : View, GestureDetector.IOnGestureListener { public bool OnDown(MotionEvent e) { return true; } public bool OnFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { return true; } public bool OnScroll(MotionEvent e1, MotionEvent e2, float distanceX, float...