Skip to content

Padding on ImageButtons works wrong on Android #13101

@matzeteo

Description

@matzeteo

Description

If you add padding to an ImageButton on Android, not only a padding will be set, but also a margin with the size of the padding. The button will therefore become smaller due to the padding. To get the button back to the right size, you then need to set a margin with a negative size.

Steps to Reproduce

  1. Create a new Maui App
  2. Create a Grid
  3. Add a ImageButton to the Grid
  4. Set a Padding on the ImageButton
  5. Add a Button to the Grid to see the Size difference
  6. It should be now like:
 <Grid ColumnDefinitions="*,100,100,*" RowDefinitions="*,100,*">
        <ImageButton Grid.Column="1" Grid.Row="1" Padding="10" BackgroundColor="Aqua" Source="dotnet_bot.png"/>
        <Button Grid.Column="2" Grid.Row="1" Text="testButton" Padding="10" BackgroundColor="Blue" WidthRequest="100" HeightRequest="100"/>
    </Grid>

Link to public reproduction project repository

https://github.com/matzeteo/TestApps.git

Version with bug

8.0 (current)

Last version that worked well

Affected platforms

Android

Affected platform versions

Android 10.0 and up

Did you find any workaround?

Set a margin with the negative value of the padding. But that doesn't work for every Layout structure.

Relevant log output

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions