-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix [Android] Image AspectFill is not honored #25072
base: main
Are you sure you want to change the base?
Changes from 8 commits
728f057
40bbf36
5d13aa2
d20892a
15706a6
e1e90f5
f24989d
a206789
acac849
c92cd20
b5156b2
817d888
5155904
f7cc1b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue21368"> | ||
|
||
|
||
<HorizontalStackLayout Spacing="40" Padding="10"> | ||
<VerticalStackLayout> | ||
<Image Source="dotnet_bot.png" Aspect="AspectFit" HeightRequest="40" WidthRequest="50" | ||
HorizontalOptions="Center" VerticalOptions="Center"/> | ||
<Label Text="AspectFit" AutomationId="Label"/> | ||
</VerticalStackLayout> | ||
<VerticalStackLayout> | ||
<Image Source="dotnet_bot.png" Aspect="AspectFill" WidthRequest="50" HeightRequest="40" | ||
HorizontalOptions="Center" VerticalOptions="Center"/> | ||
<Label Text="AspectFill"/> | ||
</VerticalStackLayout> | ||
</HorizontalStackLayout> | ||
|
||
</ContentPage> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Maui.Controls.Sample.Issues; | ||
|
||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 21368, "Image AspectFill is not honored", PlatformAffected.Android)] | ||
public partial class Issue21368 : ContentPage | ||
{ | ||
public Issue21368() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues | ||
{ | ||
public class Issue21368 : _IssuesUITest | ||
{ | ||
public override string Issue => "Image AspectFill is not honored"; | ||
|
||
public Issue21368(TestDevice device) : base(device) | ||
{ | ||
} | ||
|
||
[Test] | ||
[Category(UITestCategories.Image)] | ||
[FailsOnMac] | ||
public void VerifyImageAspects() | ||
{ | ||
App.WaitForElement("Label"); | ||
VerifyScreenshot(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,11 @@ public static void Clear(this ImageView imageView) | |
|
||
public static void UpdateAspect(this ImageView imageView, IImage image) | ||
{ | ||
if (image.Aspect is Aspect.AspectFill) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I delete this code the test still passes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A new test has been added, and now the test only passes when the fix is applied. This ensures that the fix is correctly addressing the issue, and without it, the test fails as expected. |
||
imageView.SetAdjustViewBounds(false); | ||
else | ||
imageView.SetAdjustViewBounds(true); | ||
|
||
imageView.SetScaleType(image.Aspect.ToScaleType()); | ||
} | ||
|
||
|
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.
Triggered the build, it should generate the reference snapshot for this test.