Skip to content
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

ImageButton with CornerRadius is not calculated as expected on Android when Padding exists #11874

Closed
YiannisBourkelis opened this issue Dec 5, 2022 · 11 comments
Labels
area-controls-button Button, ImageButton platform/android 🤖 s/no-repro Can no longer be reproduced on latest s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@YiannisBourkelis
Copy link

YiannisBourkelis commented Dec 5, 2022

Description

Trying to create a circular ImageButton, I am setting the CornerRadius half the width of the control, but on Android it does not appear as expected. If I remove the Padding it works, but it should also work with padding.

On iOS, MacCatalyst and Windows it works fine, however the text inside the ImageButton is not aligned exactly at the center of the ImageButton and appears a little blurry.

corner_radius_issue

This is the code that creates the ImageButton

            <ImageButton
                x:Name="AddItemImageButton"
                HorizontalOptions="End"
                VerticalOptions="End"
                CornerRadius="25"
                WidthRequest="50"
                HeightRequest="50"
                BackgroundColor="DodgerBlue"
                Padding="8,8,8,8" >                
                <ImageButton.Source>
                    <FontImageSource FontFamily="OpenSansRegular" Color="White"  Glyph="+" />
                </ImageButton.Source>                           
            </ImageButton>

Check the reproduction project.

Steps to Reproduce

Just run the reproduction project targeting Android. The ImageButton will not appear as a circle.

Link to public reproduction project repository

https://github.com/YiannisBourkelis/maui_issues/tree/main/src/CornerRadiusIssue

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, Windows, macOS

Affected platform versions

Android Emulator - Pixel 5 - Api 33

Did you find any workaround?

No.

Relevant log output

No response

@YiannisBourkelis YiannisBourkelis added the t/bug Something isn't working label Dec 5, 2022
@Eilon Eilon added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Dec 5, 2022
@PureWeen PureWeen added this to the Backlog milestone Dec 6, 2022
@ghost
Copy link

ghost commented Dec 6, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@PureWeen
Copy link
Member

PureWeen commented Dec 6, 2022

@YiannisBourkelis can you attach a screen shot please?

@YiannisBourkelis
Copy link
Author

@PureWeen Yes. It is the reproducible project running on android on the left and iOS on the right.

corner_radius_issue

@MhAllan
Copy link

MhAllan commented Apr 14, 2023

any updates on this basic thing? It was right on XF!!

@thomaskaelin
Copy link

I also noticed this issue while migrating an Xamarin.Forms-app to .NET MAUI. Any news on this?

@XamlTest XamlTest added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jun 9, 2023
@XamlTest
Copy link

XamlTest commented Jun 9, 2023

Verified this on Visual Studio Enterprise 17.7.0 Preview 1.0 with provided project:
CornerRadiusIssue.zip

iOS 16.4: Can repro the text inside the ImageButton is not aligned exactly at the center of the ImageButton issue.
image

Android 13.0-API33: Can repro the CornerRadius issue.
image

Windows 11: Seems work as expected.
image

@jsuarezruiz
Copy link
Contributor

Hi @YiannisBourkelis,

Have done some tests with the latest version and cannot reproduce the issue:
image

Could you try again with the latest version and share your feedback?. Thanks in advance.

@jsuarezruiz jsuarezruiz added the s/needs-info Issue needs more info from the author label Jun 9, 2023
@ghost
Copy link

ghost commented Jun 9, 2023

Hi @YiannisBourkelis. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@ghost ghost added the s/no-recent-activity Issue has had no recent activity label Jun 13, 2023
@ghost
Copy link

ghost commented Jun 13, 2023

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@thomaskaelin
Copy link

thomaskaelin commented Jun 13, 2023

@jsuarezruiz I ran the example posted by @XamlTest with my installation of Visual Studio Professional 2022 (Version 17.6.2) on an Android Device (Android 11 - API 30). I was able to reproduce the CornerRadius-issue with the provided code.

CornerRadius Issue

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author s/no-recent-activity Issue has had no recent activity labels Jun 13, 2023
@davidortinau
Copy link
Contributor

davidortinau commented Jul 6, 2023

Looks correct in .NET 8 Preview 6. Not sure when this was fixed. Tested on API 33 and 32.

On older versions, you can work around this with math. On Android adjust the w/h by 16 to offset the padding of 8.

<ImageButton
    x:Name="AddItemImageButton"
    HorizontalOptions="End"
    VerticalOptions="End"
    CornerRadius="25"
    WidthRequest="{OnPlatform 50, Android=66}"
    HeightRequest="{OnPlatform 50, Android=66}"
    BackgroundColor="DodgerBlue"
    Padding="8,8,8,8" >                
    <ImageButton.Source>
        <FontImageSource FontFamily="OpenSansRegular" Color="White"  Glyph="+" />
    </ImageButton.Source>                           
</ImageButton>
Screenshot 2023-07-06 at 1 50 46 PM

@samhouts samhouts added s/no-repro Can no longer be reproduced on latest and removed s/needs-attention Issue has more information and needs another look labels Jul 6, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Aug 6, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-button Button, ImageButton platform/android 🤖 s/no-repro Can no longer be reproduced on latest s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants