Last active
December 10, 2019 19:04
-
-
Save magdamiu/0d42cf1042f204fa8a7fa56bf440c71d to your computer and use it in GitHub Desktop.
Snackbar should be added in a view which contains a CoordinatorLayout.
This file contains 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(view, R.string.error_occured, Snackbar.LENGTH_LONG) | |
.setAction(R.string.retry, new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
Toast.makeText(AlertsActivity.this, getString(R.string.retry_message), Toast.LENGTH_LONG).show(); | |
} | |
}); | |
snackbar.setActionTextColor(Color.RED); | |
View snackbarView = snackbar.getView(); | |
snackbarView.setBackgroundColor(ContextCompat.getColor(this, R.color.colorAccent)); | |
TextView textView = snackbarView.findViewById(com.google.android.material.R.id.snackbar_text); | |
textView.setTextColor(Color.GREEN); | |
snackbar.show(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment