Handling native touch events through the FocusView
Since our camera implementation is handling focus changes from touch events, we are required to receive these touch events from the native side. Xamarin.Forms
does not have touch events that give (x, y) coordinates, so we have to do some more custom rendering on the FocusView
. Let's start with the Android implementation this time, inside the Renderers
folder, add a new folder called FocusView
, and add a new file called FocusViewGestureDetector.cs
, and implement the following:
public class FocusViewGestureDetector : GestureDetector.SimpleOnGestureListener { #region Events public event EventHandler<MotionEvent> Touch; #endregion #region Public Methods public override void OnLongPress(MotionEvent e) { base.OnLongPress(e); } public override bool OnDoubleTap(MotionEvent e) { return base.OnDoubleTap(e); ...