Created
January 6, 2016 03:07
-
-
Save chrisjyoon/0e78b9fd6d2f45d9afd9 to your computer and use it in GitHub Desktop.
Customise Android Snackbar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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