Forum Xamarin Xamarin.Forms

Change Image opacity while touched.

I would like to change an image opacity while it's been touched ie: change opacity when finger is down, restore when finger is up, then handle Tapped event. I couldn't find any hint...
I'm using Xamarin Forms and I need this functionality on both iOS and Android.
Any clue would be very much appreciated. Please note that I am not using XAML as per my client request. So any example must be in C# only.

Thank you in advance for your help.


  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    TapGestureRecognizer could help you?

  • Maurizio.PanzicaMaurizio.Panzica USMember ✭✭

    Well, I already use it:

    var tgr = new TapGestureRecognizer();
    tgr.Tapped += (sender, e) => { DoSomething(); }
    myImage.GestureRecognizers.Add (tgr);

    What I need is to change the opacity WHILE the image is touched and restore it when it is released.
    Just to give the user a visual feedback of the image being "clicked". Did I make myself clear? :-)

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    You should take a look to mr gesture

  • Maurizio.PanzicaMaurizio.Panzica USMember ✭✭

    I am aware of MrGesture, but unfortunately that is not an option.
    I've got strict direction as for development tools.
    I am not allowed to use any third party tools which are not free and/or require royalties.

  • MaharshiChoudhuryMaharshiChoudhury INMember ✭✭✭

    Well you can use a device.startimer and run a function which can restore the opacity of the image once you have tapped it. The only problem with that approach is that your opacity will change back to normal after a certain period of time even if you have not released the image tap

Sign In or Register to comment.