GestureRecognizer is not working on android using Xamarin.forms RRS feed

  • Question

  • User158077 posted

    public void EnableSubmitButton(){ LeftMenuItem.IsEnabled = true; TapGestureRecognizer OnLeftMenuItemClicked = new TapGestureRecognizer ((s,e) => { OnSubmitClicked (s,e); }); LeftMenuItem.GestureRecognizers.Add (OnLeftMenuItemClicked); }

    This is the code which is used to add gesture recognizer into the Image. It's working on iOS perfectly. But In android OnLeftMenuItemClicKed is not triggered.

    Thanks in Advance.

    Tuesday, September 15, 2015 5:24 PM

All replies

  • User89714 posted

    @JayaKumar.6615 - I am having a similar problem on Android. If I don't explicitly change IsEnabled it's fine. Looks like a Xamarin bug to me. Have you reported it in Bugzilla?

    Monday, October 12, 2015 2:04 PM
  • User89714 posted

    @JayaKumar.6615 - I've added it to Bugzilla at https://bugzilla.xamarin.com/show_bug.cgi?id=34760 . Please add any extra details that you think would be useful.

    Monday, October 12, 2015 2:17 PM
  • User72577 posted

    This still appears to be broken in

    Thursday, October 29, 2015 9:05 PM
  • User132171 posted

    Same issue happens in reverse. In my case I'm changing IsEnabled (which is bound to a property in the viewmodel) to False which will disable normal controls, but won't disable an image with a gesturerecognizer. If I set the property to false in the code behind it'll disable it when the page displays so the page itself is built right, it just won't respond to any changes in it.

    Monday, November 16, 2015 2:45 AM
  • User84670 posted

    Add InputTransparent="true" to all of your children in the LeftMenuItem and probably you will get it done. The problem happens because one of the LeftMenuItem's children is getting the tap gesture instead of the LeftMenuItem.

    Tuesday, November 17, 2015 11:18 AM
  • User151333 posted

    Facing same issue. Please help.

    Wednesday, January 20, 2016 8:10 AM
  • User89714 posted

    Xamarin have just marked this as not producible in bugzilla. If anybody has a piece of code to hand that demonstrates this, can you attach it to the bug at https://bugzilla.xamarin.com/show_bug.cgi?id=34760 please.

    Wednesday, January 27, 2016 8:16 PM
  • User159623 posted

    There is a bug open for a similar issue: https://bugzilla.xamarin.com/show_bug.cgi?id=38655

    Sunday, February 21, 2016 9:07 PM
  • User245084 posted

    GestureRecognizer is not working on IOS using Xamarin.forms

    can anyone help me to fix this issue

    Tuesday, August 23, 2016 11:22 AM
  • User250990 posted

    I am having this problem when I change a Controls IsEnabled property true->false->true at which point the GestureRecognizer stops working. As a workaround I am faking IsEnabled by setting opacity of the control, as I bind a Command to my recognizer it wont fire anyway (via the commands canExecuteFunc). This is obviously not ideal.

    Saturday, March 4, 2017 2:27 AM
  • User203497 posted

    I confirm this issue. The TapGestureRecognizer doesn't fire any more after changing the IsEnabled-Property from true->false->true. I tried everything: Removing and adding a new TapGestureRecognizer or unsubscribing and subscribing the Tapped event doesn't help as well.

    Wednesday, March 29, 2017 6:19 AM
  • User182627 posted

    Can confirm this issues. TapGestureRecognizer does't work on Android or iOS. Followed their samples: https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/gestures/tap/

    Thursday, April 20, 2017 7:26 PM
  • User266789 posted

    I noticed that Gesture recognizers don't work on certain elements/views.

    For example I tried setting up a gesture recognizer on a PickerView but it only allows its built in tap gesture as the only event.

    Thursday, April 20, 2017 8:14 PM
  • User211233 posted

    Hi guys,

    I have the issue (Pan doesn't work, but it does for UWP) and I would like to know how did you fixed it? did you find any work around?

    Tahnk !

    Sunday, June 18, 2017 11:24 PM
  • User285725 posted

    I'm building a custom control, it extends AbsoluteLayout. In the constructor, I setup this... it works on ios, but not on android, anyone knows what could be the problem ?

    ctor { ... GestureRecognizers.Add(new TapGestureRecognizer { Command = TransitionCommand }); }

    private ICommand TransitionCommand { get { return command ?? (command = new Command(() => { if (Command != null) Command.Execute(CommandParameter); })); } }

    Wednesday, July 19, 2017 7:22 PM
  • User285725 posted

    Well I should have tried that before... but it doesn't work on android when setting the gesture recognizer on the absolute layout, but it works when setting it on the boxview or image inside...

    Wednesday, July 19, 2017 7:32 PM
  • User263 posted

    Attaching GestureRecognizer's to layouts can be problematic. Try attaching to a View instead.

    Wednesday, July 19, 2017 8:33 PM
  • User323063 posted

    @Momm said: Add InputTransparent="true" to all of your children in the LeftMenuItem and probably you will get it done. The problem happens because one of the LeftMenuItem's children is getting the tap gesture instead of the LeftMenuItem.

    This solution works for me. Thank you!

    Friday, July 21, 2017 6:01 AM
  • User97071 posted

    @Momm thanks for this, your workaround works :)

    Monday, September 4, 2017 8:55 AM
  • User87283 posted

    This is known bug in prior versions of Xamarin.Forms. Its fixed in 2.4.0-pre1. See https://bugzilla.xamarin.com/show_bug.cgi?id=36703

    Friday, December 8, 2017 11:00 AM
  • User87283 posted

    Surprised to see that this bug was reported in 2015 and Xamarin took 2 years to release the fix.

    Friday, December 8, 2017 11:01 AM
  • User384312 posted

    I still have this issue with android. This is my Xaml code to set it up:

            Source="{Binding HTMLFile}" 
                NumberOfTapsRequired="1" />
            <SwipeGestureRecognizer Direction="Left" Swiped="Handle_SwipedLeft"/>
            <SwipeGestureRecognizer Direction="Right" Swiped="Handle_SwipedRight"/>

    and the handlers which only work with iOS:

        void Handle_SwipedLeft(object sender, Xamarin.Forms.SwipedEventArgs e)
            flashCard.HTMLFile = getHTMLFileFromDevice("FlashCard2.html");
        void Handle_SwipedRight(object sender, Xamarin.Forms.SwipedEventArgs e)
            flashCard.HTMLFile = getHTMLFileFromDevice("FlashCard3.html");
        void Handle_Tapped(object sender, System.EventArgs e)
            flashCard.HTMLFile = getHTMLFileFromDevice("FlashCard3.html");
    Sunday, April 7, 2019 10:10 AM