Skip to content

Commit

Permalink
Merge pull request #9782 from MartinZikmund/dev/mazi/elevation-androi…
Browse files Browse the repository at this point in the history
…d-scale

fix: Properly scale shadow on Android
  • Loading branch information
MartinZikmund authored Sep 9, 2022
2 parents 9096840 + 5c5f6b4 commit 88d7a40
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Uno.UI.Toolkit/ElevatedView.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 88d7a40

Please sign in to comment.