question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Snackbar Material 3 theme overlay

See original GitHub issue

Description: I am following the Material 2 doc for Snackbar. However it does not apply with Material 3, how can we style Snackbar in Material 3 because currently none of the specified value color gets applied.

Source code:

<!-- Snackbar style on both light and night mode -->
    <style name="AppSnackbar" parent="Widget.Material3.Snackbar">
        <item name="materialThemeOverlay">@style/ThemeOverlay.App.Snackbar</item>
        <item name="actionTextColorAlpha">1</item>
    </style>

    <style name="Widget.App.SnackbarButton" parent="Widget.Material3.Button.TextButton.Snackbar">
        <item name="android:textColor">@color/colorPrimary_Accent</item>
    </style>

    <style name="ThemeOverlay.App.Snackbar" parent="">
        <!-- Text color -->
        <item name="colorPrimary">@color/colorPrimary_Accent</item>
        <!-- Background color -->
        <item name="colorSurface">@color/colorWhite_Primary</item>
        <item name="colorOnSurface">@color/colorWhite_Primary</item>
    </style>

Usage <item name="snackbarStyle">@style/AppSnackbar</item>

Android API version: 21

Material Library version: 1.7.0-alpha01

Device: Samsung J1

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
drchencommented, Apr 26, 2022

Actually you can. But the color attribute you need to override is ?attr/colorSurfaceInverse. : )

1reaction
dsn5ftcommented, Apr 25, 2022

Hi @ArcherEmiya05, this is the source code for the layout used by Snackbar.

Instead of snackbarStyle, can you try using snackbarTextViewStyle (extend from Widget.Material3.Snackbar.TextView) and snackbarButtonStyle (extend from Widget.Material3.Button.TextButton.Snackbar) in your theme?

I think that should work and give you full flexibility for text colors and other attributes for the message / action button, but feel free to reopen if you’re still having issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Snackbars - Material Design
Snackbars provide brief feedback about an operation through a message at ... Diagram of the 3 parts of snackbar including Text label, Container,...
Read more >
Theming Material Design Snackbars in Android with Example
In this article, it's been discussed how we can theme material design Snackbar and increase the User Experience.
Read more >
Snackbar - Android Developers
Snackbars provide lightweight feedback about an operation. They show a brief message at the bottom of the screen on mobile and lower left...
Read more >
Android Snackbar Example - Medium
Android Snackbar is an interesting component introduced by Material Design. ... Snackbar"> <item name="materialThemeOverlay">@style/ThemeOverlay.
Read more >
material-components-android/Snackbar.md at master - GitHub
Material3.Button.TextButton.Snackbar"> <item name="android:textColor">@color/shrine_pink_100</item> </style> <style name="ThemeOverlay.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found