question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
MhAllancommented, Apr 14, 2023

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

1reaction
PureWeencommented, Dec 6, 2022

@YiannisBourkelis can you attach a screen shot please?

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Padding not working on ImageButton
this issue about scaleType default, in the ImageButton that is fitXY, you just need to change fitCenter. <ImageButton android:layout_width="24dp ...
Read more >
R.attr | Android Developers
Quickly bring your app to life with less code, using a modern declarative approach to UI, and the simplicity of Kotlin. ... Start...
Read more >
How To Create Round Buttons in Xamarin Forms
This article is about how you can easily create your own round buttons with a few simple lines of XAML, no code and...
Read more >
androidx.compose.material
Executes when the user tries to dismiss the Dialog by clicking outside or pressing the back button. This is not called when the...
Read more >
Xamarin.Forms 4.4.0.991537 (4.4.0 Service Release 3) ...
The existing Image control now supports rendering GIF images. This is intended for small, short animations. Caching and streaming is not ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found