I am showing snackbar in DialogFragment Within the Positive click of alertDialog. Here is my code snippet.
Snackbar snackbar = Snackbar.make(view, \"Please e
As none of the other answers provided a custom style override (that I consider one of the safest update way to do that) I post here my solution.
I post a solution that already address the new AndroidX
(support design 28
) theme.
Provided that your application use a custom them called MyAppTheme
in your AndroidManifest.xml
:
Create (if you haven't already) values/style.xml
file overriding the theme used by your application:
and provide your colors in your values/colors.xml
file
#008577
#00574B
#D81B60
#D81B60
UPDATE 2020
As the above solution removes the round corner of the snacker bacause setting the background this way uses the legacy snackbar design, if you want to preserve the material design you can.
replace android:background
with android:backgroundTint
If you are targeting API < 21 then if you decide to use legacy snackbar for API < 21 you could set your abouve MySnackbarStyle
in res/values-21/ folder and leave the previous — legacy — style in your res/values folder.
If you are targeting API < 21 and you want to have the material style of the snackbar also in this lower API levels you can change your snackbar style in your res/values/ this way:
and borrow your my_snackbar_background
from the official repo, this way:
Here is a playground repo.