Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue23854.cs
Original file line number Diff line number Diff line change
@@ -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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you include a couple of samples using the BorderWidth and BorderColor properties?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rounding doesn't quite work with non-transparent images with borderWidth and borderColor. @mattleibow was writing about it here #21259 (comment)

{
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
}
}
};
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending snapshots already available in the latest build.
image

Could you commit the images?

}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions src/Core/src/Platform/Android/MauiRippleDrawableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Comment on lines +62 to +65
Copy link

Copilot AI Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] You can reduce repetition by using a single builder method (e.g., SetAllCornerSizes or an equivalent) to apply the same radius to all corners in one call, which improves readability and maintainability.

Suggested change
.SetTopLeftCorner(CornerFamily.Rounded, radius)
.SetTopRightCorner(CornerFamily.Rounded, radius)
.SetBottomLeftCorner(CornerFamily.Rounded, radius)
.SetBottomRightCorner(CornerFamily.Rounded, radius)
.SetAllCorners(CornerFamily.Rounded, radius)

Copilot uses AI. Check for mistakes.
.Build();
}

return true;
}

Expand Down
Loading