java.lang.Object | |
↳ | android.support.design.widget.Snackbar |
Snackbars provide lightweight feedback about an operation. They show a brief message at the bottom of the screen on mobile and lower left on larger devices. Snackbars appear above all other elements on 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. Snackbars can be swiped off screen.
Snackbars can contain an action which is set via
setAction(CharSequence, android.view.View.OnClickListener)
.
To be notified when a snackbar has been shown or dismissed, you can provide a Snackbar.Callback
via setCallback(Callback)
.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Snackbar.Callback |
Callback class for Snackbar instances.
|
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | LENGTH_INDEFINITE | Show the Snackbar indefinitely. | |||||||||
int | LENGTH_LONG | Show the Snackbar for a long period of time. | |||||||||
int | LENGTH_SHORT | Show the Snackbar for a short period of time. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Dismiss the
Snackbar .
| |||||||||||
Return the duration.
| |||||||||||
Returns the
Snackbar 's view.
| |||||||||||
Return whether this Snackbar is currently being shown.
| |||||||||||
Make a Snackbar to display a message.
| |||||||||||
Make a Snackbar to display a message
Snackbar will try and find a parent view to hold Snackbar's view from the value given
to | |||||||||||
Set the action to be displayed in this
Snackbar .
| |||||||||||
Set the action to be displayed in this
Snackbar .
| |||||||||||
Sets the text color of the action specified in
setAction(CharSequence, View.OnClickListener) .
| |||||||||||
Sets the text color of the action specified in
setAction(CharSequence, View.OnClickListener) .
| |||||||||||
Set a callback to be called when this the visibility of this
Snackbar changes.
| |||||||||||
Set how long to show the view for.
| |||||||||||
Update the text in this
Snackbar .
| |||||||||||
Update the text in this
Snackbar .
| |||||||||||
Show the
Snackbar .
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Show the Snackbar indefinitely. This means that the Snackbar will be displayed from the time
that is shown
until either it is dismissed, or another Snackbar is shown.
Show the Snackbar for a long period of time.
Show the Snackbar for a short period of time.
Return whether this Snackbar is currently being shown.
Make a Snackbar to display a message.
Snackbar will try and find a parent view to hold Snackbar's view from the value given
to view
. Snackbar will walk up the view tree trying to find a suitable parent,
which is defined as a CoordinatorLayout
or the window decor's content view,
whichever comes first.
Having a CoordinatorLayout
in your view hierarchy allows Snackbar to enable
certain features, such as swipe-to-dismiss and automatically moving of widgets like
FloatingActionButton
.
view | The view to find a parent from. |
---|---|
resId | The resource id of the string resource to use. Can be formatted text. |
duration | How long to display the message. Either LENGTH_SHORT or LENGTH_LONG
|
Make a Snackbar to display a message
Snackbar will try and find a parent view to hold Snackbar's view from the value given
to view
. Snackbar will walk up the view tree trying to find a suitable parent,
which is defined as a CoordinatorLayout
or the window decor's content view,
whichever comes first.
Having a CoordinatorLayout
in your view hierarchy allows Snackbar to enable
certain features, such as swipe-to-dismiss and automatically moving of widgets like
FloatingActionButton
.
view | The view to find a parent from. |
---|---|
text | The text to show. Can be formatted text. |
duration | How long to display the message. Either LENGTH_SHORT or LENGTH_LONG
|
Set the action to be displayed in this Snackbar
.
resId | String resource to display |
---|---|
listener | callback to be invoked when the action is clicked |
Set the action to be displayed in this Snackbar
.
text | Text to display |
---|---|
listener | callback to be invoked when the action is clicked |
Sets the text color of the action specified in
setAction(CharSequence, View.OnClickListener)
.
Sets the text color of the action specified in
setAction(CharSequence, View.OnClickListener)
.
Set a callback to be called when this the visibility of this Snackbar
changes.
Set how long to show the view for.
duration | either be one of the predefined lengths:
LENGTH_SHORT , LENGTH_LONG , or a custom duration
in milliseconds.
|
---|
Update the text in this Snackbar
.
resId | The new text for the Toast. |
---|
Update the text in this Snackbar
.
message | The new text for the Toast. |
---|