diff --git a/src/Core/src/Graphics/MauiDrawable.Android.cs b/src/Core/src/Graphics/MauiDrawable.Android.cs index 666cbc7524f0..f67d74e52ab8 100644 --- a/src/Core/src/Graphics/MauiDrawable.Android.cs +++ b/src/Core/src/Graphics/MauiDrawable.Android.cs @@ -321,6 +321,13 @@ public void SetBorderLineCap(LineCap lineCap) InvalidateSelf(); } + public void InvalidateBorderBounds() + { + _bounds = null; + + InvalidateSelf(); + } + protected override void OnBoundsChange(ARect? bounds) { if (_bounds != bounds) diff --git a/src/Core/src/Handlers/Border/BorderHandler.Android.cs b/src/Core/src/Handlers/Border/BorderHandler.Android.cs index 1d8b09aa32bb..76465dce171f 100644 --- a/src/Core/src/Handlers/Border/BorderHandler.Android.cs +++ b/src/Core/src/Handlers/Border/BorderHandler.Android.cs @@ -46,6 +46,18 @@ static void UpdateContent(IBorderHandler handler) handler.PlatformView.AddView(view.ToPlatform(handler.MauiContext)); } + public static void MapHeight(IBorderHandler handler, IBorderView border) + { + handler.PlatformView?.UpdateHeight(border); + handler.PlatformView?.InvalidateBorderStrokeBounds(); + } + + public static void MapWidth(IBorderHandler handler, IBorderView border) + { + handler.PlatformView?.UpdateWidth(border); + handler.PlatformView?.InvalidateBorderStrokeBounds(); + } + public static void MapContent(IBorderHandler handler, IBorderView border) { UpdateContent(handler); @@ -59,4 +71,4 @@ protected override void DisconnectHandler(ContentViewGroup platformView) base.DisconnectHandler(platformView); } } -} +} \ No newline at end of file diff --git a/src/Core/src/Handlers/Border/BorderHandler.cs b/src/Core/src/Handlers/Border/BorderHandler.cs index 62b4caf5b4f8..4299a9b7f134 100644 --- a/src/Core/src/Handlers/Border/BorderHandler.cs +++ b/src/Core/src/Handlers/Border/BorderHandler.cs @@ -15,6 +15,10 @@ public partial class BorderHandler : IBorderHandler { public static IPropertyMapper Mapper = new PropertyMapper(ViewMapper) { +#if __ANDROID__ + [nameof(IContentView.Height)] = MapHeight, + [nameof(IContentView.Width)] = MapWidth, +#endif [nameof(IContentView.Background)] = MapBackground, [nameof(IContentView.Content)] = MapContent, [nameof(IBorderStroke.Shape)] = MapStrokeShape, diff --git a/src/Core/src/Platform/Android/StrokeExtensions.cs b/src/Core/src/Platform/Android/StrokeExtensions.cs index 008226d19026..66d3dc2101d2 100644 --- a/src/Core/src/Platform/Android/StrokeExtensions.cs +++ b/src/Core/src/Platform/Android/StrokeExtensions.cs @@ -7,7 +7,7 @@ public static class StrokeExtensions { public static void UpdateBorderStroke(this AView platformView, IBorderStroke border) { - //Always set the drawable first + // Always set the drawable first platformView.UpdateMauiDrawable(border); var borderShape = border.Shape; @@ -119,6 +119,14 @@ public static void UpdateStrokeLineJoin(this AView platformView, IBorderStroke b mauiDrawable?.SetBorderLineJoin(border.StrokeLineJoin); } + public static void InvalidateBorderStrokeBounds(this AView platformView) + { + if (platformView.Background is not MauiDrawable mauiDrawable) + return; + + mauiDrawable.InvalidateBorderBounds(); + } + internal static void UpdateMauiDrawable(this AView platformView, IBorderStroke border) { bool hasBorder = border.Shape != null && border.Stroke != null; @@ -139,6 +147,7 @@ internal static void UpdateMauiDrawable(this AView platformView, IBorderStroke b mauiDrawable.SetBackground(v.Background); else mauiDrawable.SetBackground(new SolidPaint(Colors.Transparent)); + mauiDrawable.SetBorderShape(border.Shape); } }