Forum Xamarin.Forms

How to fit an image to the size of your button using xaml?

CarkCark GBUniversity ✭✭
edited March 2017 in Xamarin.Forms

Hi,

I'm very new to Xamarin.Forms and XAML in general.

I'm currently doing a basic app where I want to have a button displayed as a barcode scanner image. However, the image I am using doesn't fit the button as it's too big and only shows a small portion of the image I want to use when using the HorizontalOptions property. When I'm not using the property, the button will expand to the real size of the image which is big.

Here's the code:

If you could help, that would be perfect.

Thanks.

Best Answer

Answers

  • SheraShera INMember ✭✭
    Accepted Answer

    @Cark Why don't you use small size image ??

  • VinayakGawasVinayakGawas USMember ✭✭✭

    Where is the code???

  • Gigex42Gigex42 USMember ✭✭✭✭

    If you only want the Image to be pressed you can use GestureRecognizer

    myImage.GestureRecognizers.Add(new TapGestureRecognizer
    {
             Command = new Command(() => Do Stuff)
    });
    

    Else some code would be good.

  • CarkCark GBUniversity ✭✭

    Code unfortunately got cut! I have no idea why. I ended up just doing what Shera recommended and using a smaller image to fit the size of the button I wanted (I'm using XAML to do my UI and not c#.).

    Thanks, Shera!

Sign In or Register to comment.