Skip to content

[Android] ImageButton CornerRadius not being applied - fix #30074

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Jun 19, 2025

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issues Fixed

Fixes #23854

Before After

@Copilot Copilot AI review requested due to automatic review settings June 19, 2025 15:29
@kubaflo kubaflo requested a review from a team as a code owner June 19, 2025 15:29
@kubaflo kubaflo requested review from jsuarezruiz and Aguilex June 19, 2025 15:29
@kubaflo kubaflo self-assigned this Jun 19, 2025
Copy link
Contributor

Hey there @@kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jun 19, 2025
@kubaflo kubaflo added area-controls-button Button, ImageButton platform/android and removed community ✨ Community Contribution labels Jun 19, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that the CornerRadius on ImageButton controls is correctly applied on Android by updating the material ShapeAppearanceModel for ShapeableImageView. It also adds a reproduction sample and a UI test to catch regressions.

  • Extend UpdateMauiRippleDrawableStroke to adjust the ShapeAppearanceModel when the platform view is a ShapeableImageView
  • Add a UI test in TestCases.Shared.Tests to verify corner radius rendering
  • Add a sample page in TestCases.HostApp demonstrating the issue

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Core/src/Platform/Android/MauiRippleDrawableExtensions.cs Added ShapeableImageView handling to apply rounded corners
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue23854.cs Added a UI test that waits for the ImageButton and takes a screenshot
src/Controls/tests/TestCases.HostApp/Issues/Issue23854.cs Added a sample page with multiple ImageButton configurations

Comment on lines +59 to +62
.SetTopLeftCorner(CornerFamily.Rounded, radius)
.SetTopRightCorner(CornerFamily.Rounded, radius)
.SetBottomLeftCorner(CornerFamily.Rounded, radius)
.SetBottomRightCorner(CornerFamily.Rounded, radius)
Copy link
Preview

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.

@kubaflo kubaflo added the community ✨ Community Contribution label Jun 19, 2025
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

public void CornerRadiusShouldBeApplied()
{
App.WaitForElement("ImageButton");
VerifyScreenshot();
Copy link
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?

{
protected override void Init()
{
Content = new VerticalStackLayout
Copy link
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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-button Button, ImageButton community ✨ Community Contribution platform/android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ImageButton CornerRadius not being applied on Android
2 participants