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][Android] Padding is incorrect after IsVisible is changed #18001

Open
haavamoa opened this issue Oct 13, 2023 · 3 comments · May be fixed by #25223
Open

[ImageButton][Android] Padding is incorrect after IsVisible is changed #18001

haavamoa opened this issue Oct 13, 2023 · 3 comments · May be fixed by #25223
Labels
area-controls-button Button, ImageButton migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@haavamoa
Copy link

Description

Hello, and thank you for this awesome framework.

I've noticed a bug where ImageButtons for Android does not correctly set their Padding. I first thought it happened every time you draw a ImageButton, but that was not the case. It happens whenever you change the IsVisible property, which in many cases people are I presume.

In the follow example I have a ImageButton with the dotnet_bot as source and a red background. I've set the Padding to 50, which should make the bot smaller inside the button. This works the first time the app loads, but once I change the IsVisible (using the Switch) it ignores the Padding.

Screen.Recording.2023-10-13.at.13.56.55.mov

Steps to Reproduce

  1. Clone this repository.
  2. Select Android
  3. Run the code
  4. Observe the ImageButton has the correct padding once it loads.
  5. Observe the ImageButton not having the correct padding when you tap the Switch.

Link to public reproduction project repository

https://github.com/haavamoa/MauiApp/tree/task/hmo-imagebutton-padding-android

Version with bug

8.0.0-rc.2.9373

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

The way to get around this the issue where IsVisible is flipped is to make sure to update the padding after the IsVisible has changed:

Here is our fix, where we ship a wrapping ImageButton class.

Relevant log output

No response

@haavamoa haavamoa added the t/bug Something isn't working label Oct 13, 2023
@Eilon Eilon added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Oct 13, 2023
@samhouts samhouts added the migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert label Oct 16, 2023
@XamlTest XamlTest added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Oct 17, 2023
@XamlTest
Copy link

Verified this on Visual Studio Enterprise 17.8.0 Preview 3.0(8.0.0-rc.2.9373). Repro on Android 13.0-API33, not repro on iOS 16.4 with below Project:
MauiApp.zip
ImageButton

@haavamoa
Copy link
Author

Another work around is to use Button with ImageSource in stead.

From my understanding, this is a bug with ImageButtons ShapeableImageView on Android, where a Button is Material Button and it works as intended there.

@mattleibow mattleibow added the area-controls-button Button, ImageButton label Oct 24, 2023
@mattleibow mattleibow added this to the Backlog milestone Oct 24, 2023
@ghost
Copy link

ghost commented Oct 24, 2023

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-button Button, ImageButton migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 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

Successfully merging a pull request may close this issue.

5 participants