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

[Android] "MaterialButton manages its own background" log message when setting BackgroundColor to Button #18898

Open
tranb3r opened this issue Nov 20, 2023 · 14 comments
Labels
area-controls-button Button, ImageButton platform/android 🤖 s/question ? Further information is requested s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@tranb3r
Copy link

tranb3r commented Nov 20, 2023

Description

When setting BackgroundColor (or Background) to Button on Android, the following message is logged, even if the functionality works:

[MaterialButton] MaterialButton manages its own background to control elevation, shape, color and states. 
Consider using backgroundTint, shapeAppearance and other attributes where available. 
A custom background will ignore these attributes and you should consider handling interaction states such as pressed, focused and disabled

Is this hidding some kind of bug? Is it possible to avoid this log?

Steps to Reproduce

  1. Open the repro project.
  2. Click on "Button test" button, it navigates to a new page with a simple Button with its BackgroundColor set in the XAML code.
  3. Observe output window, the "MatterialButton manages its own background..." message is logged

Link to public reproduction project repository

https://github.com/tranb3r/Issues/tree/main/MauiAppMaterialButtonAndCheckbox

Version with bug

8.0.3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 14

Did you find any workaround?

No response

Relevant log output

No response

@tranb3r tranb3r added the t/bug Something isn't working label Nov 20, 2023
@moljac
Copy link
Contributor

moljac commented Nov 20, 2023

Is this hidding some kind of bug? Is it possible to avoid this log?

I guess this is by design and not Maui, but Material.

https://developer.android.com/reference/com/google/android/material/button/MaterialButton#:~:text=MaterialButton%20manages%20its%20own%20background,cannot%20guarantee%20well%2Ddefined%20behavior.

@tranb3r
Copy link
Author

tranb3r commented Nov 20, 2023

Sure, the log is Material, not Maui.
But does Maui implement the MaterialButton properly?

@moljac
Copy link
Contributor

moljac commented Nov 20, 2023

But does Maui implement the MaterialButton properly?

Not sure. I am not pixel-moving expert. Maui probably allows changing background (legacy other to have the same API with other platforms), but modern Material does not like it. Don't know. I must dive in.

@Eilon Eilon added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Nov 21, 2023
@rachelkang rachelkang added the migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert label Jan 23, 2024
@bcaceiro
Copy link

bcaceiro commented Mar 2, 2024

I am also getting these logs. I imagine this hurts performance

@mydaycare-carefree
Copy link

mydaycare-carefree commented Mar 19, 2024

We're also getting these logs, a lot of them! Do we stop using Buttons?

@akhilvswoodplc
Copy link

akhilvswoodplc commented Apr 10, 2024

Any update on this. This seems to slow down rendering if there are buttons in a collectionview item

@ninachen03 ninachen03 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Apr 11, 2024
@ninachen03
Copy link

Verified this issue with Visual Studio 17.10.0 Preview 3 (8.0.20 & 8.0.0-rc.2.9530). Can repro it with sample project
image

@bcaceiro
Copy link

Any news on this? I have this spamming in my output window

@Eilon Eilon added area-controls-button Button, ImageButton and removed legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor labels May 13, 2024
@mnxamdev
Copy link

mnxamdev commented Jun 4, 2024

This is also affecting release build performance. When will this get fixed so we can actually release our MAUI app?

@jsuarezruiz jsuarezruiz added this to the Backlog milestone Jun 5, 2024
@Mysame
Copy link

Mysame commented Jun 24, 2024

This is half our app's logging.

@mattleibow
Copy link
Member

I am also getting these logs. I imagine this hurts performance

Any evidence of this?

@mattleibow
Copy link
Member

This is not a bug, maui replaces the background because material does not support many of the features we want nor does it properly lay out the image and text.

@mattleibow mattleibow added s/question ? Further information is requested and removed t/bug Something isn't working migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert labels Jun 27, 2024
@mattleibow
Copy link
Member

Any update on this. This seems to slow down rendering if there are buttons in a collectionview item

If a collection view is reusing views, this will only appear the very first time a button is created as there is a check https://github.com/material-components/material-components-android/blob/release-1.12/lib/java/com/google/android/material/button/MaterialButton.java#L439

@tranb3r
Copy link
Author

tranb3r commented Jun 27, 2024

maui replaces the background because material does not support many of the features we want nor does it properly lay out the image and text.

Then, why do Maui use a MaterialButton, instead of an AppCompatButton or a Button?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-button Button, ImageButton platform/android 🤖 s/question ? Further information is requested 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