Reputation: 340
I'm using Google Design library (23.1.0) to show snackbars. My snackbar code lookls like:
Snackbar snackbar = Snackbar.make(getView(), "Deleted", Snackbar.LENGTH_LONG);
snackbar.setActionTextColor(getResources().getColor(R.color.accent_color));
snackbar.setAction(R.string.undo, //anonymous class omitted);
snackbar.setCallback(//anonymous class omitted);
snackbar.show();
The snackbar is being created and shown. Action label, action color, and all listeners works as expected. The only thing is that the message "Deleted" is not being shown. If I use debugger and stop execution on: snackbar.show(), I can see that inside snackbar > mView > mMessageView there is a field called mText and it has value of "Deleted". Yet I cannot see the message on the snackbar. I have tried already using both string consts and resources id.
Whats more, I have tried using very similar code in clean project and it works. What might be the cause?
Upvotes: 0
Views: 3486
Reputation: 340
Oh, it looks like the text color was really the same as background. I've replaced:
Snackbar snackbar = Snackbar.make(getView(), "Deleted", Snackbar.LENGTH_LONG);
With:
Snackbar snackbar = Snackbar.make(fab, Html.fromHtml("<font color=\"#ffffff\">Deleted</font>"), Snackbar.LENGTH_LONG);
And now I can see the text.
Update:
After a little futher investigation the default color for snackbar text is taken from theme.xml. I case of our project the value of textColor was set to #313131 and the background of snackbar is #323232. Impossible to notice.
Upvotes: 1
Reputation: 2391
Maybe something is wrong with the color of text (R.color.accent_color). Maybe text color as background color?
Try without this option:
Snackbar snackbar = Snackbar.make(getView(), "Deleted", Snackbar.LENGTH_LONG);
snackbar.setAction(R.string.undo, //anonymous class omitted);
snackbar.setCallback(//anonymous class omitted);
snackbar.show();
Upvotes: 0