Button Image property not scaling

CaseCase USMember ✭✭✭

I am trying to use a Button with an Image.
My image file is a 225x225 png file (with transparent background).

                    <Button Grid.Column="2" 
                            Image="options_dots.png"
                            Scale="0.2"
                            Margin="2,2,2,2"
                            Command="{Binding ShowOptionsCommand}" 
                            HorizontalOptions="Center"
                            VerticalOptions="Center"
                            BackgroundColor="{StaticResource SoftBlue}"/>

Although the button is indeed scaled to 20%, it is taking up the same amount of space around it as if it were at 100%

Best Answer

Answers

  • CaseCase USMember ✭✭✭

    Thanks, I was using a grid anyways and just figured that out.
    I put an image then a button with transparent background.

    The other thing I learned is that the scale property on the image doesn't work as expected.
    If I scale the 225x225 image to 20% using Scale="0.2" it does indeed scale, but, still consumes the space as if it were full size.

    To fix that I use Width and Height Request - then the image takes up only that space.

    Next things is to figure out rounded corners ... loathing having to use custom renderers. The whole reason I want to use Xamarin.Forms is to avoid writing custom device dependent code!

Sign In or Register to comment.