dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.04k stars 1.73k forks source link

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

Open tranb3r opened 10 months ago

tranb3r commented 10 months ago

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

moljac commented 10 months ago

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 commented 10 months ago

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

moljac commented 10 months ago

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.

bcaceiro commented 7 months ago

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

mydaycare-carefree commented 6 months ago

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

akhilvswoodplc commented 5 months ago

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

ninachen03 commented 5 months ago

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 commented 5 months ago

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

mnxamdev commented 4 months ago

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

Mysame commented 3 months ago

This is half our app's logging.

mattleibow commented 3 months ago

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

Any evidence of this?

mattleibow commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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?