I need the AppTheme.colorAccent
to be brown but I need my Snackbar
action color to be blue. How to change action button color of Snackbar
from style without changing AppTheme.colorAccent
?
I've try this code but it does not work :
<style name="TextAppearance.Design.Snackbar" parent="android:TextAppearance" tools:override="true">
<item name="colorAccent">#3097ff</item>
</style>
With the Material Components Library you can do it.
Just add the snackbarButtonStyle
attribute in your theme app.
<style name="AppTheme" parent="Theme.MaterialComponents.*">
<!-- Style to use for action button within a Snackbar in this theme. -->
<item name="snackbarButtonStyle">@style/snackbar_button</item>
...
</style>
Then define your custom style:
<style name="snackbar_button" parent="@style/Widget.MaterialComponents.Button.TextButton.Snackbar">
<item name="backgroundTint">@color/secondaryLightColor</item>
<item name="android:textColor">@color/primaryDarkColor</item>
</style>
It requires the version 1.1.0 of the library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With