androidmaterial-components-androidandroid-dark-theme

Material3 replacement for PrimarySurface


I've started to replace styles with the new Material3 ones (Material You) which are present in the latest Material Design Components library. However, I don't see a replacement for Widget.MaterialComponents.Toolbar.PrimarySurface (a style that handles dark mode better by not using the primary color, which looks to bright). There's Widget.Material3.Toolbar, Widget.Material3.Toolbar.Surface and Widget.Material3.Toolbar.OnSurface but I don't think any of them is a replacement.

Am I missing something here?


Solution

  • Widget.MaterialComponents.Toolbar.PrimarySurface style is just a combination of Widget.MaterialComponents.Toolbar.Primary and Widget.MaterialComponents.Toolbar.Surface styles for light and dark mode.

    That means this style uses colorPrimary in light mode and colorSurface in dark mode.

    In the Material 3 (Material you) , the default background color for the toolbar is changed from colorPrimary to colorSurface.

    You can always customize these material 3 themes according to your preference.