O'Reilly logo

Xamarin Mobile Development for Android Cookbook by Matthew Leibowitz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. For most gestures, we implement the IOnGestureListener interface. As we are going to implement scrolling and flicking, we return true for the OnDown(), OnFling(), and OnScroll() methods. Because we are not concerned with the screen taps, we return false for the OnSingleTapUp() method:
    public class MyView : View, GestureDetector.IOnGestureListener { public bool OnDown(MotionEvent ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required