maui: SwipeGestureRecognizer is not working

Description

SwipeGestureRecognizer is not working on Android, the Swiped event is never raised. I only found this issue #14 which says its in Pending state but the issue hasn’t been updated since 2 years. The documentation for MAUI sounds like it’s implemented.

Is this a bug or is it really not implemented yet?

Steps to Reproduce

<Button>
          <Button.GestureRecognizers>
                    <SwipeGestureRecognizer Direction="Right" Swiped="SwipeGestureRecognizer_Swiped"/>
          </Button.GestureRecognizers>
</Button>

SwipeGestureRecognizer_Swiped event is never raised when I swipe in Android Simulator.

Version with bug

Release Candidate 3 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 12, API 31, Android Simulator

Did you find any workaround?

No response

Relevant log output

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 28 (16 by maintainers)

Most upvoted comments

repro with VladislavAntonyuk’s sample.

I confirm this issue still exists in .NET MAUI 7. I added swipe gesture to a content view. In Android, the gesture never works!!

@jsuarezruiz please try my sample: https://github.com/VladislavAntonyuk/MauiSamples/blob/main/CardLayout/CardsLayout.cs#L86 Replace PanGestureRecognizer with SwipeGestureRecognizer. PanGestureRecognizer fires events but SwipeGestureRecognizer doesn’t. https://github.com/dotnet/maui/issues/7403#issuecomment-1172064417

Today I tested Gesture Detector Handlers on Android, and custom control extending ContentView. Everything worked (Pan, Pinch, Tap) except Swipe. Maui 7.0. This is important feature, not only for custom controls.

I can confirm what @VladislavAntonyuk said. PanGestureRecognizer is also working for me (as soon as I click, hold and drag the mouse in the emulator, the event is raised), but SwipeGestureRecognizer does not. I click, hold and drag, nothing happens and the Swiped event is never raised.

These were the changes I made:

	public CardsLayout()
	{
		var panGesture = new SwipeGestureRecognizer();
		panGesture.Swiped += PanGesture_Swiped;
		GestureRecognizers.Add(panGesture);
	}

	private void PanGesture_Swiped(object? sender, SwipedEventArgs e)
	{
		throw new NotImplementedException(); // <-- never raised
	}