Snackbar Material 3 theme overlay
See original GitHub issueDescription: 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:
- Created a year ago
- Comments:7 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Actually you can. But the color attribute you need to override is
?attr/colorSurfaceInverse
. : )Hi @ArcherEmiya05, this is the source code for the layout used by Snackbar.
Instead of
snackbarStyle
, can you try usingsnackbarTextViewStyle
(extend fromWidget.Material3.Snackbar.TextView
) andsnackbarButtonStyle
(extend fromWidget.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.