diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CornerRadiusShouldBeApplied.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CornerRadiusShouldBeApplied.png new file mode 100644 index 000000000000..1d98fa18b8f5 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CornerRadiusShouldBeApplied.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/ImageSourceInitializesCorrectly.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/ImageSourceInitializesCorrectly.png index 7c397c537c83..130e5106068e 100644 Binary files a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/ImageSourceInitializesCorrectly.png and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/ImageSourceInitializesCorrectly.png differ diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue23854.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue23854.cs new file mode 100644 index 000000000000..51f65e8a0b7a --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue23854.cs @@ -0,0 +1,49 @@ +namespace Maui.Controls.Sample.Issues; + +[Issue(IssueTracker.Github, 23854, "ImageButton CornerRadius not being applied on Android", PlatformAffected.Android)] +public class Issue23854 : TestContentPage +{ + protected override void Init() + { + Content = new VerticalStackLayout + { + Spacing = 10, + Children = + { + new ImageButton + { + AutomationId = "ImageButton", + HeightRequest = 50, + WidthRequest = 50, + CornerRadius = 25, + Source = "vegetables.png", + Aspect = Aspect.AspectFill + }, + new ImageButton + { + HeightRequest = 50, + WidthRequest = 100, + CornerRadius = 25, + Source = "vegetables.png", + Aspect = Aspect.AspectFill + }, + new ImageButton + { + HeightRequest = 100, + WidthRequest = 50, + CornerRadius = 25, + Source = "vegetables.png", + Aspect = Aspect.AspectFill + }, + new ImageButton + { + HeightRequest = 20, + WidthRequest = 100, + CornerRadius = 20, + Source = "vegetables.png", + Aspect = Aspect.AspectFill + } + } + }; + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/CornerRadiusShouldBeApplied.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/CornerRadiusShouldBeApplied.png new file mode 100644 index 000000000000..92af498b7511 Binary files /dev/null and b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/CornerRadiusShouldBeApplied.png differ diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue23854.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue23854.cs new file mode 100644 index 000000000000..14710c1c4fc3 --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue23854.cs @@ -0,0 +1,20 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; + +public class Issue23854 : _IssuesUITest +{ + public Issue23854(TestDevice testDevice) : base(testDevice) { } + + public override string Issue => "ImageButton CornerRadius not being applied on Android"; + + [Test] + [Category(UITestCategories.ImageButton)] + public void CornerRadiusShouldBeApplied() + { + App.WaitForElement("ImageButton"); + VerifyScreenshot(); + } +} diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/CornerRadiusShouldBeApplied.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/CornerRadiusShouldBeApplied.png new file mode 100644 index 000000000000..d3e663bfff31 Binary files /dev/null and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/CornerRadiusShouldBeApplied.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/CornerRadiusShouldBeApplied.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/CornerRadiusShouldBeApplied.png new file mode 100644 index 000000000000..bd6afd1f05fb Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/CornerRadiusShouldBeApplied.png differ diff --git a/src/Core/src/Platform/Android/MauiRippleDrawableExtensions.cs b/src/Core/src/Platform/Android/MauiRippleDrawableExtensions.cs index 21851c2a6aa7..2dc286c6c690 100644 --- a/src/Core/src/Platform/Android/MauiRippleDrawableExtensions.cs +++ b/src/Core/src/Platform/Android/MauiRippleDrawableExtensions.cs @@ -3,6 +3,8 @@ using Android.Content; using Android.Content.Res; using Android.Graphics.Drawables; +using Google.Android.Material.ImageView; +using Google.Android.Material.Shape; using Microsoft.Maui.Graphics; using AColor = Android.Graphics.Color; using AView = Android.Views.View; @@ -50,6 +52,20 @@ internal static bool UpdateMauiRippleDrawableStroke(this AView platformView, IBu gradientDrawable.SetCornerRadius(radius); maskDrawable.SetCornerRadius(radius); + if (platformView is ShapeableImageView shapeableImageView) + { + // Update the ShapeAppearanceModel to match the stroke radius + // so that the corners are rounded correctly. + shapeableImageView.ShapeAppearanceModel = + shapeableImageView.ShapeAppearanceModel + .ToBuilder() + .SetTopLeftCorner(CornerFamily.Rounded, radius) + .SetTopRightCorner(CornerFamily.Rounded, radius) + .SetBottomLeftCorner(CornerFamily.Rounded, radius) + .SetBottomRightCorner(CornerFamily.Rounded, radius) + .Build(); + } + return true; }