Stats

522 Contributors: 19 Tuesday, July 18, 2017
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

Snackbar

Syntax

  • Snackbar make (View view, CharSequence text, int duration)
  • Snackbar make (View view, int resId, int duration)

Parameters

ParameterDescription
viewView: The view to find a parent from.
textCharSequence: The text to show. Can be formatted text.
resIdint: The resource id of the string resource to use. Can be formatted text.
durationint: How long to display the message. This can be LENGTH_SHORT, LENGTH_LONG or LENGTH_INDEFINITE

Remarks

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'
}

Official Documentation

https://developer.android.com/reference/android/support/design/widget/Snackbar.html

Related Examples