Skip to content

Instantly share code, notes, and snippets.

@chrisjyoon
Created January 6, 2016 03:07
Show Gist options
  • Save chrisjyoon/0e78b9fd6d2f45d9afd9 to your computer and use it in GitHub Desktop.
Save chrisjyoon/0e78b9fd6d2f45d9afd9 to your computer and use it in GitHub Desktop.
Customise Android Snackbar
Snackbar snackbar = Snackbar.make(findViewById(R.id.main_content), "TEST", Snackbar.LENGTH_INDEFINITE);
View snackbarView = snackbar.getView();
// change background color of snackbar
snackbarView.setBackgroundColor(ContextCompat.getColor(this, R.color.my_color));
// align text to right end and add image icon to left
TextView textView = (TextView)snackbarView.findViewById(android.support.design.R.id.snackbar_text);
textView.setTextSize(16);
textView.setGravity(Gravity.END | Gravity.CENTER_VERTICAL);
textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_test, 0, 0, 0);
snackbar.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment