Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Core/src/Handlers/Image/ImageHandler2.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ protected override ShapeableImageView CreatePlatformView()
{
var imageView = new ShapeableImageView(MauiMaterialContextThemeWrapper.Create(Context));

// Clear any forced per-view layer type (e.g. a hardware layer) to avoid blurry scaling when the view is transformed.
imageView.SetLayerType(global::Android.Views.LayerType.None, null);
Comment thread
SubhikshaSf4851 marked this conversation as resolved.
Resolved
// Enable view bounds adjustment on measure.
// This allows the ImageView's OnMeasure method to account for the image's intrinsic
// aspect ratio during measurement, which gives us more useful values during constrained
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Android.Graphics.Drawables;
using Android.Widget;
using Microsoft.Maui.DeviceTests.Stubs;
using Google.Android.Material.ImageView;
using Xunit;

namespace Microsoft.Maui.DeviceTests
Expand Down Expand Up @@ -103,6 +104,21 @@ await handler.PlatformView.AttachAndRun(async () =>
});
}

[Fact]
public async Task ImageHandler2PlatformViewDoesNotUseHardwareLayer()
{
var image = new TStub();

await InvokeOnMainThreadAsync(() =>
{
var handler = CreateHandler<ImageHandler2>(image);
var platformView = Assert.IsType<ShapeableImageView>(handler.PlatformView);

Assert.Equal(global::Android.Views.LayerType.None, platformView.LayerType);
});
}


ImageView GetPlatformImageView(IImageHandler imageHandler) =>
imageHandler.PlatformView;

Expand Down
Loading