I'm trying to change the background color of the material toolbar to the surface color with:
android:background="?attr/colorSurface"
which works as expected (to simplify it I set the background color directly at the view and did not create a custom style for that). In order to define multiple colors for light and dark mode I created two colors.xml files. When in light mode the applied surface color looks as expected:
But when I'm changing to dark mode the two toolbars look like this (still both referencing the same color resource):
The right toolbar has the correct background color, the left one not.
Then I checked if the same thing happens with every color I define in dark mode so I changed the surface color to my primary color. In dark mode it looks like this:
So in this case the colors look the same, but when I'm using my surface color, it does not.
I also tried to change the Widget.MaterialComponents.Toolbar.Surface toolbar to Widget.MaterialComponents.Toolbar, but still the same result.
Widget.MaterialComponents.Toolbar.PrimarySurface
style in yourMaterialToolbar
. – Gabriele MariottielevationOverlayEnabled
to false solved it, weird that this effect still gets applied when the elevation is set to 0. Thank you for your help. – Timo S.