material-components-android
material-components-android copied to clipboard
Question about Button changes in 1.11.0
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>
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.
Closing due to answer above and lack of updates. Deel free to comment again and reopen if there's still an issue!