2

Can anyone guide me how to make background of a snackbar transparent?

Thanks

2 Answers2

2
Snackbar snackbar = Snackbar.make(mainView, text, Snackbar.LENGTH_LONG);
View snackBarView = snackbar.getView();
snackBarView.setBackgroundColor(context.getResources().getColor(R.color.yourcolor));
snackbar.show();

you can define your color as transparent in values.

GianhTran
  • 3,443
  • 2
  • 22
  • 42
  • Tried this but no success. I picked the default android snackbar which is grey in color. I am able to add or change colors on it but unable to remove the background or make it transparent. – Varun Sahdev Apr 23 '19 at 08:13
  • 1
    snackBarView.setBackgroundResource(R.color.trans); Where trans → #00000000 . – edward kenway Apr 23 '19 at 08:18
0

For newcomers (Kotlin)

snackbar.view.setBackgroundColor(Color.TRANSPARENT)

It will remove the background from Snackbar

Usman Zafer
  • 1,261
  • 1
  • 10
  • 15