0
votes

I'm creating a cross platform app using Xamarin Forms. I did all my testing in iOS and the app looks perfect. When I view the Android project in the Xamarin Previewer, the buttons' images are way too big. Since all my images are hi res, I created some smaller, low res ones and put them in the drawable folder and moved my other images to drawable-hdpi. I expected the buttons to resize to the images but that's not the case. I remember reading somewhere how to handle this but after 2 days of searching I can't seem to find it. The button is in a Grid and defined like this:

 <Button x:Name="facebookBtn" Grid.Column="1" Grid.Row="5" Image="facebook_btn.png"/>

Here's what the button looks like:

Button with Image

1
In your case I use the Image as it (not a button) and set a TapGestureRecognizer to it. This way you can create your image (as you want it to be rendered) .pinedax
That definitely works but I loose some of the effects from a button such as when it is pressed. The button shows a press effect.jbassking10
Are there any other suggestions?jbassking10
Does my solution answers your question?Cfun
@Cfun I fixed this back in 2017.jbassking10

1 Answers

0
votes

I know at the time of the question probably ImageButton was not available , but now you can use ImageButton instead, this way you will also preserve the click effect of the button as stated in your comment.

<ImageButton x:Name="facebookBtn" Grid.Column="1" Grid.Row="5"
             Source="facebook_btn.png" Aspect="AspectFill"/>