Reputation: 5615
I am using https://github.com/nispok/snackbar library for Snackbar implementation. I want this snackbar to be white, so I wrote code like this :
SnackbarManager.show(Snackbar.with(context)
.text(R.string.you_have_to_be_logged_in)
.color(Color.WHITE)
.actionLabel(R.string.log_me_in)
.actionColorResource(R.color.lime_500)
.actionListener(new ActionClickListener() {
@Override
public void onActionClicked(Snackbar snackbar) {
LogInDialog logInDialog = new LogInDialog();
logInDialog.show(ft, "LogInDialog");
}
}));
As you can see in line 3 I set background color to white, but it doesn't change anything. The background is still dark. But, if I change background color to .colorResource(R.color.lime_500)
the snackbar will change to this color.
I have also tried .colorResource(R.color.white)
and .color(Color.parseColor("#ffffff")
.
Why the snackbar cannot be white?
Upvotes: 3
Views: 4889
Reputation: 13302
this will change the color or snackbar to blue
Snackbar snack = Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null);
ViewGroup group = (ViewGroup) snack.getView();
group.setBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.red));
snack.show();
Upvotes: 0
Reputation: 1666
Snackbar snackbar = Snackbar.make(linearLayout, getResources().getString(R.string.add_number), Snackbar.LENGTH_LONG);
snackbar.setActionTextColor(Color.WHITE);
View snackbarView = snackbar.getView();
snackbarView.setBackgroundColor(Color.RED);
snackbar.show();
Upvotes: 1
Reputation: 1203
This was indeed a bug and has been fixed in version 2.8.0
The problem was that it was assumed that a color value of -1
meant that the color was not defined and should use the default Material Design spec values. Turns out Color.WHITE
IS -1
thus it was ignored :P
Now, the "undefined" color value is set to -10000
; this value should not cause any problems.
Upvotes: 1