diff --git a/src/Core/src/Platform/Android/ButtonExtensions.cs b/src/Core/src/Platform/Android/ButtonExtensions.cs index 42619df645f8..e9ead52f7cb5 100644 --- a/src/Core/src/Platform/Android/ButtonExtensions.cs +++ b/src/Core/src/Platform/Android/ButtonExtensions.cs @@ -59,7 +59,9 @@ internal static void UpdateButtonStroke(this MaterialButton platformView, IButto internal static void UpdateButtonBackground(this MaterialButton platformView, IButton button) { - platformView.UpdateMauiRippleDrawableBackground(button, + platformView.UpdateMauiRippleDrawableBackground( + button.Background, + button, () => { // Copy the tints from a temporary button. diff --git a/src/Core/src/Platform/Android/ImageButtonExtensions.cs b/src/Core/src/Platform/Android/ImageButtonExtensions.cs index 50fdf8921142..d6a9b2158bac 100644 --- a/src/Core/src/Platform/Android/ImageButtonExtensions.cs +++ b/src/Core/src/Platform/Android/ImageButtonExtensions.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Google.Android.Material.ImageView; using Google.Android.Material.Shape; +using Microsoft.Maui.Graphics; namespace Microsoft.Maui.Platform { @@ -76,7 +77,9 @@ internal static void UpdateButtonStroke(this ShapeableImageView platformView, IB internal static void UpdateButtonBackground(this ShapeableImageView platformView, IImageButton button) { - platformView.UpdateMauiRippleDrawableBackground(button, + platformView.UpdateMauiRippleDrawableBackground( + button.Background ?? new SolidPaint(Colors.Transparent), // transparent to force some background + button, beforeSet: () => { // We have a background, so we need to remove the things that were set on the diff --git a/src/Core/src/Platform/Android/MauiRippleDrawableExtensions.cs b/src/Core/src/Platform/Android/MauiRippleDrawableExtensions.cs index 1918effccad3..3b0270fa7a14 100644 --- a/src/Core/src/Platform/Android/MauiRippleDrawableExtensions.cs +++ b/src/Core/src/Platform/Android/MauiRippleDrawableExtensions.cs @@ -50,14 +50,13 @@ internal static bool UpdateMauiRippleDrawableStroke(this AView platformView, IBu return true; } - internal static void UpdateMauiRippleDrawableBackground(this AView platformView, TButton button, + internal static void UpdateMauiRippleDrawableBackground(this AView platformView, + Paint? background, + IButtonStroke stroke, Func? getEmptyBackgroundColor = null, Func? getDefaultRippleColor = null, Action? beforeSet = null) - where TButton : IButtonStroke, IView { - var background = button.Background; - // Get the current background var recreateRipple = false; if (!platformView.TryGetMauiBackground(out var rippleDrawable, out var layerDrawable, out _, out var strokeDrawable, out _)) @@ -74,7 +73,7 @@ internal static void UpdateMauiRippleDrawableBackground(this AView plat recreateRipple = true; } - var (width, color, radius) = button.GetStrokeProperties(platformView.Context!, false); + var (width, color, radius) = stroke.GetStrokeProperties(platformView.Context!, false); // The previous background may have had transparency or a gradient which cannot // be un-set, so we need an entirely new drawable. @@ -132,7 +131,7 @@ internal static void UpdateMauiRippleDrawableBackground(this AView plat // Create the stroke layer. strokeDrawable = new GradientDrawable(); strokeDrawable.SetCornerRadius(radius); - var strokeColor = button.StrokeColor ?? Colors.Black; + var strokeColor = stroke.StrokeColor ?? Colors.Black; var strokeColorList = ColorStateListExtensions.CreateButton(strokeColor.ToPlatform()); strokeDrawable.SetStroke(width, strokeColorList);