From 5c5f6b4751760eceabd2f5d258fe30b9329d64d9 Mon Sep 17 00:00:00 2001 From: Martin Zikmund Date: Fri, 9 Sep 2022 18:35:56 +0200 Subject: [PATCH] fix: Properly scale shadow on Android --- src/Uno.UI.Toolkit/ElevatedView.Android.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Uno.UI.Toolkit/ElevatedView.Android.cs b/src/Uno.UI.Toolkit/ElevatedView.Android.cs index 9e3999132f32..fa8771f03e92 100644 --- a/src/Uno.UI.Toolkit/ElevatedView.Android.cs +++ b/src/Uno.UI.Toolkit/ElevatedView.Android.cs @@ -69,12 +69,13 @@ private void DrawShadow(AndroidCanvas canvas) { var viewHeight = ActualHeight; var viewWidth = ActualWidth; + var scaleFactor = GetScaleFactorForLayoutRounding(); // If bounds is zero if (viewHeight != 0 && viewWidth != 0) { - var bitmapHeight = viewHeight + MaximumRadius; - var bitmapWidth = viewWidth + MaximumRadius; + var bitmapHeight = (viewHeight + MaximumRadius) * scaleFactor; + var bitmapWidth = (viewWidth + MaximumRadius) * scaleFactor; // Reset bitmap to bounds _shadowBitmap = AndroidBitmap.CreateBitmap( @@ -109,8 +110,8 @@ private void DrawShadow(AndroidCanvas canvas) _shadowPaint.SetMaskFilter(new BlurMaskFilter(radius, BlurMaskFilter.Blur.Normal)); } - float shadowOffsetX = (float)Elevation * x; - float shadowOffsetY = (float)Elevation * y; + float shadowOffsetX = (float)(Elevation * x * scaleFactor); + float shadowOffsetY = (float)(Elevation * y * scaleFactor); _shadowCanvas.DrawBitmap(extractAlpha!, (int)shadowOffsetX, (int)shadowOffsetY, _shadowPaint);