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

[Android] Fix shadows size in clipped views #11603

Merged
merged 8 commits into from
Feb 10, 2023
Merged
Changes from 5 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
9 changes: 6 additions & 3 deletions src/Core/src/Platform/Android/WrapperView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public partial class WrapperView : ViewGroup
const int MaximumRadius = 100;

readonly Android.Graphics.Rect _viewBounds;
readonly Context _context;

APath _currentPath;
SizeF _lastPathSize;
Expand All @@ -32,6 +33,7 @@ public WrapperView(Context context)
: base(context)
{
_viewBounds = new Android.Graphics.Rect();
_context = context;

SetClipChildren(false);
SetWillNotDraw(true);
Expand Down Expand Up @@ -146,15 +148,15 @@ partial void BorderChanged()

if (_borderView == null)
{
AddView(_borderView = new AView(Context));
AddView(_borderView = new AView(_context));
}

_borderView.UpdateBorderStroke(Border);
}

void ClipChild(Canvas canvas)
{
var density = Context.GetDisplayDensity();
var density = _context.GetDisplayDensity();
var newSize = new SizeF(canvas.Width, canvas.Height);
var bounds = new Graphics.RectF(Graphics.Point.Zero, newSize / density);

Expand Down Expand Up @@ -268,7 +270,8 @@ void DrawShadow(Canvas canvas)
else
{
var bounds = new Graphics.RectF(0, 0, canvas.Width, canvas.Height);
var path = Clip.PathForBounds(bounds)?.AsAndroidPath();
var density = _context.GetDisplayDensity();
var path = Clip.PathForBounds(bounds)?.AsAndroidPath(scaleX: density, scaleY: density);

path.Offset(shadowOffsetX, shadowOffsetY);

Expand Down