-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix ImageButton not rendering correctly based on its bounds #28309
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
base: main
Are you sure you want to change the base?
Conversation
|
Hey there @Shalini-Ashokan! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super-nit: After #28040, you can convert this to file-scope namespace by CTRL+. in Visual Studio (I believe it's the same in VS Code).
If it is converted, then new files will use file-scope namespaces more and more as people IMO copy old files to create new code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion , I have changed the file-scope namespace.
| if (image.Aspect == Aspect.AspectFill) | ||
| imageView.SetAdjustViewBounds(false); | ||
| else | ||
| imageView.SetAdjustViewBounds(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Code style for "new code" should be:
| if (image.Aspect == Aspect.AspectFill) | |
| imageView.SetAdjustViewBounds(false); | |
| else | |
| imageView.SetAdjustViewBounds(true); | |
| if (image.Aspect == Aspect.AspectFill) | |
| { | |
| imageView.SetAdjustViewBounds(false); | |
| } | |
| else | |
| { | |
| imageView.SetAdjustViewBounds(true); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MartyIX, Thanks for the suggestion, I have updated the code style.
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
| public void Issue25558VerifyImageButtonAspects() | ||
| { | ||
| App.WaitForElement("imageButton"); | ||
| VerifyScreenshot(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsuarezruiz, I have committed the image.
|
|
||
| [Test] | ||
| [Category(UITestCategories.ImageButton)] | ||
| public void Issue25558VerifyImageButtonAspects() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is failing on Windows:
at UITest.Appium.HelperExtensions.Wait(Func`1 query, Func`2 satisfactory, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2367
at UITest.Appium.HelperExtensions.WaitForAtLeastOne(Func`1 query, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2384
at UITest.Appium.HelperExtensions.WaitForElement(IApp app, String marked, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency, Nullable`1 postTimeout) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 665
at Microsoft.Maui.TestCases.Tests.Issues.Issue25558.Issue25558VerifyImageButtonAspects() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25558.cs:line 19
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsuarezruiz, I have modified the test to resolve the failing.
|
@jsuarezruiz, The Issue18242Test failure is related to my changes. Previously, the ImageButton without a specified height was not rendering correctly. Shall I commit the newly generated image? |
In that case, yes. |
@jsuarezruiz, I have committed the failure image. |
|
/rebase |
d88c6af to
71b4c79
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/rebase |
e1fdd77 to
6cadf7d
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/rebase |
6cadf7d to
8a174ad
Compare
|
/rebase |
This reverts commit 277d167.
8a174ad to
af2e61c
Compare
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |



Issue Details
The ImageButton image rendered on Android was not adjusting its bounds correctly, leading to improper scaling.
Root Cause
The image button was not rendering based on its bounds value.
Description of Change
In ImageButton Android Handler, set true for SetAdjustViewBounds(), when you enable view bounds adjustment, the ImageView will automatically resize to maintain the image's aspect ratio.
Validated the behavior in the following platforms
Issues Fixed
Fixes #25558
Fixes #14346
Output ScreenShot