Parameter | Description |
---|---|
view | View: The view to find a parent from. |
text | CharSequence: The text to show. Can be formatted text. |
resId | int: The resource id of the string resource to use. Can be formatted text. |
duration | int: How long to display the message. This can be LENGTH_SHORT, LENGTH_LONG or LENGTH_INDEFINITE |
Snackbar provides lightweight feedback about an operation. It displays a brief message at the bottom of the screen on mobile and at the bottom left on larger devices. Snackbars appear above all other elements on the screen and only one can be displayed at a time.
They automatically disappear after a timeout or after user interaction elsewhere on the screen, particularly after interactions that summon a new surface or activity. Snackbar can be swiped off screen.
Before using SnackBar
you must add the design support library dependency in the build.gradle
file:
dependencies {
compile 'com.android.support:design:25.3.1'
}
https://developer.android.com/reference/android/support/design/widget/Snackbar.html