Snackbar

SESL variant 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.

Snackbars can contain an action which is set via setAction.

Snackbars automatically disappear after a timeout. They can also be dismissed by being swiped off screen, by action click, from a new snackbar being displayed, or manually via a call to dismiss.

To be notified when a snackbar has been shown or dismissed, you can provide a Callback via addCallback.

For more information, see the component developer guidance and design guidelines.

Types

Link copied to clipboard
Callback class for Snackbar instances.
Link copied to clipboard
Link copied to clipboard
class SnackbarLayout : BaseTransientBottomBar.SnackbarBaseLayout

Properties

Link copied to clipboard
The default Snackbar type.
Link copied to clipboard
A snackbar type with a more prominent style and entry animation.

Functions

Link copied to clipboard
open fun dismiss()
Link copied to clipboard
open fun getDuration(): Int
Return the duration.
Link copied to clipboard
Returns the TextView responsible for displaying the message in this Snackbar.
Link copied to clipboard
open fun isShown(): Boolean
Return whether this BaseTransientBottomBar is currently being shown.
Link copied to clipboard
open fun make(@NonNull view: View, @StringRes resId: Int, duration: Int): Snackbar
Make a Snackbar to display a message.
open fun make(@NonNull view: View, @NonNull text: CharSequence, duration: Int): Snackbar
open fun make(@NonNull context: Context, @NonNull view: View, @NonNull text: CharSequence, duration: Int): Snackbar
open fun make(@NonNull view: View, @NonNull text: CharSequence, duration: Int, type: Int): Snackbar
open fun make(@NonNull context: Context, @NonNull view: View, @NonNull text: CharSequence, duration: Int, type: Int): Snackbar
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.
Link copied to clipboard
@CanIgnoreReturnValue
open fun setAction(@StringRes resId: Int, listener: View.OnClickListener): Snackbar
@CanIgnoreReturnValue
open fun setAction(@Nullable text: CharSequence, @Nullable listener: View.OnClickListener): Snackbar
Set the action to be displayed in this BaseTransientBottomBar.
Link copied to clipboard
@CanIgnoreReturnValue
open fun setActionTextColor(colors: ColorStateList): Snackbar
@CanIgnoreReturnValue
open fun setActionTextColor(@ColorInt color: Int): Snackbar
Sets the text color of the action specified in setAction.
Link copied to clipboard
@CanIgnoreReturnValue
open fun setBackgroundTint(@ColorInt color: Int): Snackbar
Sets the tint color of the background Drawable.
Link copied to clipboard
@CanIgnoreReturnValue
open fun setBackgroundTintList(@Nullable colorStateList: ColorStateList): Snackbar
Sets the tint color state list of the background Drawable.
Link copied to clipboard
@CanIgnoreReturnValue
open fun setBackgroundTintMode(@Nullable mode: PorterDuff.Mode): Snackbar
Link copied to clipboard
@CanIgnoreReturnValue
open fun setCallback(@Nullable callback: Snackbar.Callback): Snackbar
Set a callback to be called when this the visibility of this Snackbar changes.
Link copied to clipboard
@CanIgnoreReturnValue
open fun setMaxInlineActionWidth(@Dimension width: Int): Snackbar
Sets the max width of the action to be in the same line as the message.
Link copied to clipboard
@CanIgnoreReturnValue
open fun setText(@StringRes resId: Int): Snackbar
@CanIgnoreReturnValue
open fun setText(@NonNull message: CharSequence): Snackbar
Update the text in this Snackbar.
Link copied to clipboard
@CanIgnoreReturnValue
open fun setTextColor(colors: ColorStateList): Snackbar
@CanIgnoreReturnValue
open fun setTextColor(@ColorInt color: Int): Snackbar
Sets the text color of the message specified in setText and setText.
Link copied to clipboard
@CanIgnoreReturnValue
open fun setTextMaxLines(maxLines: Int): Snackbar
Sets the max line count of the message specified in setText and setText.
Link copied to clipboard
open fun show()