material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

Question about Button changes in 1.11.0

Open ArcherEmiya05 opened this issue 1 year ago • 1 comments

Currently updating to new version of MDC and noticed a lot of colorSurface was replaced by colorSurfaceContainer*. However looking in these changes specifically Button.md the backgroundTint was replaced by colorSurfaceContainerLow. However in our theme the use colorPrimary as background which is still working and replacing it with colorSurfaceContainerLow does not work and the button disappears.

Base theme

<!-- Button style on both light and night mode -->
 <style name="AppButtonStyle" parent="Widget.Material3.Button" tools:keep="@style/AppButtonStyle">
     <item name="materialThemeOverlay">@style/ThemeOverlay.App.Button</item>
     <item name="android:textAppearance">@style/TextAppearance.App.Button</item>
     <item name="shapeAppearanceOverlay">@style/ShapeAppearance.App.SmallComponent</item>
 </style>

 <style name="ThemeOverlay.App.Button" parent="ThemeOverlay.Material3.Button" tools:keep="@style/ThemeOverlay_App_Button">
     <!-- Text color -->
     <item name="colorOnPrimary">@android:color/white</item>
     <!-- Background color -->
     <item name="colorPrimary">@color/colorPrimaryDark_Accent</item>
 </style>

Usage

    <style name="Theme.App" parent="Theme.Material3.DayNight">

          <item name="materialButtonStyle">@style/AppButtonStyle</item>

    </style>

ArcherEmiya05 avatar Dec 20 '23 12:12 ArcherEmiya05

The tonal surface color updates only updates the "elevated" button theme overlay to have colorSurfaceContainerLow (instead of colorSurface) as the container. It shouldn't affect the default button theme overlay.

However in our theme the use colorPrimary as background which is still working

The default button does use colorPrimary as container color and colorOnPrimary as label color. This is as expected.

replacing it with colorSurfaceContainerLow does not work and the button disappears

Just to confirm. Are you trying to use colorSurfaceContainerLow as the container color in your style, right? And it make the button disappear.

pekingme avatar Jan 08 '24 20:01 pekingme

Closing due to answer above and lack of updates. Deel free to comment again and reopen if there's still an issue!

leticiarossi avatar May 07 '24 22:05 leticiarossi