Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button with image not scaling to HeightRequest on iOS and Android #9734

Closed
duindain opened this issue Aug 29, 2022 · 9 comments · Fixed by #19834 or #21759
Closed

Button with image not scaling to HeightRequest on iOS and Android #9734

duindain opened this issue Aug 29, 2022 · 9 comments · Fixed by #19834 or #21759
Assignees
Labels
area-controls-button Button, ImageButton fixed-in-8.0.20 fixed-in-8.0.40 fixed-in-9.0.0-preview.3.10457 help wanted [up-for-grabs] Good issue for external contributors p/1 Work that is critical for the release, but we could probably ship without partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/android 🤖 platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@duindain
Copy link

duindain commented Aug 29, 2022

Description

Button with an image fails to correctly scale the source image to the size of the button this results in the full size image being displayed in Android and a skewed image in iOS

iOS
Simulator Screen Shot - iPad Pro (12 9-inch) (5th generation) - 2022-08-29 at 17 43 58

Android
Screenshot_1661759181

WinUI
Screenshot 2022-08-29 180009

Steps to Reproduce

Create a new example Maui App

Add the following line of xaml to MainPage.xaml

<Button
                ImageSource="dotnet_bot.png"
                Text="Im a happy button"
                HeightRequest="40"
                WidthRequest="200"/>

Run the solution, works correctly in WinUI and results in the full sized image next to the button in Android and the image skewed and distorted but with the correct height in iOS

I expect this to correctly render the image in the button to the left of the text in the button using the heightrequest to scale down to the requested height maintaining the images aspect ratio, see WinUI example above where the image and button are rendered correctly

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android

Affected platform versions

iOS 15.5, Android 33

Did you find any workaround?

Reduce the image size manually to be the correct size desired on a device

Relevant log output

No response

@duindain duindain added the t/bug Something isn't working label Aug 29, 2022
@jsuarezruiz jsuarezruiz added the area-controls-button Button, ImageButton label Aug 29, 2022
@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Aug 29, 2022
@jfversluis
Copy link
Member

You mention "Run the solution," which would indicate there is a reproduction project? Could you please link us the GitHub repo? Thank you!

@jfversluis jfversluis added the s/needs-repro Attach a solution or code which reproduces the issue label Aug 30, 2022
@ghost
Copy link

ghost commented Aug 30, 2022

Hi @duindain. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@duindain
Copy link
Author

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels Aug 31, 2022
@PureWeen PureWeen added the help wanted [up-for-grabs] Good issue for external contributors label Sep 7, 2022
@PureWeen PureWeen added this to the Backlog milestone Sep 7, 2022
@ghost
Copy link

ghost commented Sep 7, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@PureWeen PureWeen removed the s/needs-attention Issue has more information and needs another look label Sep 7, 2022
@Zhanglirong-Winnie Zhanglirong-Winnie added s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage labels May 23, 2023
@Zhanglirong-Winnie
Copy link
Collaborator

Verified this issue with Visual Studio Enterprise 17.6.0 Preview 7.0. Repro on iOS platform with sample project.
mauibuttonswithimages-main.zip
Screenshot 2023-05-23 135436

@jstedfast
Copy link
Member

I ported this sample app to Xamarin.Forms and Android looks the same as in MAUI (IOW the large png is displayed at full size even though the button is much smaller than the image).

My guess is that iOS will also render the same as in MAUI.

@jstedfast
Copy link
Member

jstedfast commented May 31, 2023

Just tested the Xamarin.Forms port on iOS and what it shows is a scaled-down image in the button, but oddly no text?

Simulator Screenshot - iPhone 14 Pro - 2023-05-31 at 14 53 09

@mikeparker104 mikeparker104 added the partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with label Aug 29, 2023
@samhouts samhouts added the p/1 Work that is critical for the release, but we could probably ship without label Aug 30, 2023
@samhouts samhouts modified the milestones: Backlog, .NET 8 SR3 Oct 3, 2023
@runnerdev
Copy link

Until this bug can be worked on, I was able to get button images to scale down and render correctly on iOS/Android via custom handlers. It is a bit of a hack for sure but seems to work for my needs.

In the ConnectHandler override of the the button handler I did the following:

Android:
Set the platformView.IconSize. I set this to platformView.MinimumHeight

iOS:
create a UIImage instance using ((Button)VirtualView).ImageSource to get the image file name.
Call platformView.SetBackgroundImage(, UIControlState.Normal)
Set the ImageSource of the VirtualView to null otherwise you end up with a scaled image and the huge image on top

@plppp2001
Copy link

plppp2001 commented Apr 6, 2024

iOS Simulators and Release on devices, button HeightRequest not working for me either, my setup:
VS 2022 -> Version 17.9.5

MAUI:

	<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.14" />
		<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.14" />
		<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
		<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-button Button, ImageButton fixed-in-8.0.20 fixed-in-8.0.40 fixed-in-9.0.0-preview.3.10457 help wanted [up-for-grabs] Good issue for external contributors p/1 Work that is critical for the release, but we could probably ship without partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/android 🤖 platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
Status: Done