Trying out the new Design Support Library, I added a snackbar; but unlike its main background, the text area is not colored with the default value of #323232
. Instead, it looks like this. It seems to take its color from the android:background
value defined in the custom theme in my styles.xml
, which goes like this:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="android:background">#4f4f5e</item>
...
</style>
If I try to forcefully color it with
View snackbarView = snackbar.getView();
snackbarView.setBackgroundColor(Color.YELLOW);
it only impacts the main background, like this, and the text background still gets colored by the custom theme. Is there a way to both keep my custom theme, and have a standard snackbar? Thanks!
To change the Snackbar's background colour you can do the following from code:
Snackbar snack = Snackbar.make(...);
ViewGroup group = (ViewGroup) snack.getView();
group.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.red));
snack.show();
Instead of red you can use the Snackbar's default colour: #323232