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 ...
Get Xamarin Mobile Development for Android Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.