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

Fix [Android] Image AspectFill is not honored #25072

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

devanathan-vaithiyanathan
Copy link
Contributor

@devanathan-vaithiyanathan devanathan-vaithiyanathan commented Oct 3, 2024

Root Cause

In Image Android Handler, set true for SetAdjustViewBounds(), when you enable view bounds adjustment, the ImageView will automatically resize to maintain the image's aspect ratio.

Description of Change

This update fixes image aspect handling for Android in ImageView, If the aspect is AspectFill, set the false for SetAdjustViewBounds(), so the view bounds are not adjusted, allowing the image to fill the view.

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed

Fixes #21368

Output Screenshot

Before After
Android
Android

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Oct 3, 2024
@jsuarezruiz jsuarezruiz added platform/android 🤖 area-image Image loading, sources, caching labels Oct 4, 2024
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

public void VerifyImageAspects()
{
App.WaitForElement("LabelNames");
VerifyScreenshot();
Copy link
Contributor

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.

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

jsuarezruiz commented Oct 14, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I delete this code the test still passes

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-image Image loading, sources, caching community ✨ Community Contribution platform/android 🤖
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android] image AspectFill is not honored
3 participants