Bug 52938 - Button should support Aspect property for Button.Image
Summary: Button should support Aspect property for Button.Image
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.3
Hardware: All Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-03-01 19:00 UTC by alex
Modified: 2018-03-30 00:40 UTC (History)
7 users (show)

Tags: bug, android, button, image ac
Is this bug a regression?: ---
Last known good build:


Attachments
screenshot of the problem (43.01 KB, image/png)
2017-03-01 19:00 UTC, alex
Details
repro project (372.54 KB, application/x-zip-compressed)
2017-03-01 23:12 UTC, Jimmy [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 52938 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description alex 2017-03-01 19:00:01 UTC
Created attachment 20066 [details]
screenshot of the problem

Xamarin.Forms XAML Button has Image property but the image is being rendered different on each platform.
iOS renderer scales image to aspect-fit container (button itself), while Android renderer use fill strategy.

Sample code:
```
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:FormsApp2" x:Class="FormsApp2.FormsApp2Page">
    <Button VerticalOptions="CenterAndExpand" WidthRequest="100" HeightRequest="50">
     <Button.Image>
         <OnPlatform x:TypeArguments="FileImageSource"
             iOS="Revolutions_Button.png"
             Android="Revolutions_Button.png" />
      </Button.Image>
</Button>
</ContentPage>
```

Revolutions_Button.png is attached.

Xamarin.Forms version 2.3.3.180/2.3.3.193
Comment 1 Jimmy [MSFT] 2017-03-01 22:11:53 UTC
Thank you for filing this report! I will run the code you provided to try confirming this issue and I will update the report accordingly.
Comment 2 Jimmy [MSFT] 2017-03-01 23:12:50 UTC
Created attachment 20075 [details]
repro project

I can reproduce this issue on Forms 2.3.3.180 and 2.3.4-pre2 using the attached project. I am confirming the report and the engineering team will look into this further.
Comment 3 Dimitar Dobrev 2018-01-04 12:31:09 UTC
When is this going to be added? While there exists a workaround with Image and TapGestureRecognizer, it's not the same because any styles and behaviour for buttons from the operating system are lost.
Comment 4 David Ortinau [MSFT] 2018-03-30 00:40:20 UTC
Perhaps should be addressed by the new ImageButton, a more appropriate control for the use case described here. https://github.com/xamarin/Xamarin.Forms/issues/1974