# Snackbar

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/snackbar/Snackbar.java)

*** ** * ** ***


```
public class Snackbar extends BaseTransientBottomBar
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [com.google.android.material.snackbar.BaseTransientBottomBar](https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar) ||
|   | ↳ | [com.google.android.material.snackbar.Snackbar](https://developer.android.com/reference/com/google/android/material/snackbar/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.

Snackbars can contain an action which is set via `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setAction(java.lang.CharSequence,View.OnClickListener)`.

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 `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#dismiss()`.

To be notified when a snackbar has been shown or dismissed, you can provide a `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar.Callback` via `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#addCallback(com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback<B>)`.

For more information, see the [component developer guidance](https://github.com/material-components/material-components-android/blob/master/docs/components/Snackbar.md) and [design guidelines](https://material.io/components/snackbar/overview).

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar.Callback extends https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar.BaseCallback` Callback class for `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` instances. |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#dismiss()()` Dismiss the `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`. |
| `int` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#getDuration()()` Return the duration. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#isShown()()` Return whether this `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar` is currently being shown. |
| `static https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#make(View,int,int)(View view, int resId, int duration)` Make a Snackbar to display a message. |
| `static https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#make(View,java.lang.CharSequence,int)(View view, https://developer.android.com/reference/java/lang/CharSequence text, int duration)` Make a Snackbar to display a message |
| `static https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#make(Context,View,java.lang.CharSequence,int)(Context context, View view, https://developer.android.com/reference/java/lang/CharSequence text, int duration)` Make a Snackbar to display a message |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setAction(int,View.OnClickListener)(int resId, OnClickListener listener)` Set the action to be displayed in this `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setAction(java.lang.CharSequence,View.OnClickListener)(https://developer.android.com/reference/java/lang/CharSequence text, OnClickListener listener)` Set the action to be displayed in this `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setActionTextColor(int)(int color)` Sets the text color of the action specified in `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setAction(java.lang.CharSequence,View.OnClickListener)`. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setActionTextColor(ColorStateList)(ColorStateList colors)` Sets the text color of the action specified in `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setAction(java.lang.CharSequence,View.OnClickListener)`. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setBackgroundTint(int)(int color)` Sets the tint color of the background Drawable. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setBackgroundTintList(ColorStateList)(ColorStateList colorStateList)` Sets the tint color state list of the background Drawable. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setBackgroundTintMode(PorterDuff.Mode)(Mode mode)` |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `[setCallback](https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setCallback(com.google.android.material.snackbar.Snackbar.Callback))(https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar.Callback callback)` **This method is deprecated.** Use `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#addCallback(com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback<B>)` <br /> |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setCloseIconDrawable(Drawable)(Drawable icon)` Set the drawable used for the optional close icon. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setCloseIconResource(int)(int iconResourceId)` Set the drawable resource used for the optional close icon. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setCloseIconTint(int)(int tint)` Set the tint color of the optional close icon. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setCloseIconTintList(ColorStateList)(ColorStateList tintList)` Set the tint list of the optional close icon. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setCloseIconVisible(boolean)(boolean visible)` Show an optional close icon at the end of the snackbar. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setMaxInlineActionWidth(int)(int width)` Sets the max width of the action to be in the same line as the message. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setText(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence message)` Update the text in this `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar`. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setText(int)(int resId)` Update the text in this `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar`. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setTextColor(int)(int color)` Sets the text color of the message specified in `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setText(java.lang.CharSequence)` and `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setText(int)`. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setTextColor(ColorStateList)(ColorStateList colors)` Sets the text color of the message specified in `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setText(java.lang.CharSequence)` and `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setText(int)`. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setTextMaxLines(int)(int maxLines)` Sets the max line count of the message specified in `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setText(java.lang.CharSequence)` and `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setText(int)`. |
| `void` | `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#show()()` Show the `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`. |

| ### Protected methods |
|---|---|
| `static boolean` | `[hasSnackbarButtonStyleAttr](https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#hasSnackbarButtonStyleAttr(Context))(Context context)` **This method is deprecated.** This is for backward compatibility with AppCompat themes. <br /> |

| ### Inherited Constants |
|---|
| From [com.google.android.material.snackbar.BaseTransientBottomBar](https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar) |---|---| | `static final int` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#ANIMATION_MODE_FADE() = 1` Animation mode that corresponds to the fade in and out animations. | | `static final int` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#ANIMATION_MODE_SLIDE() = 0` Animation mode that corresponds to the slide in and out animations. | | `static final int` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#LENGTH_INDEFINITE() = -2` Show the Snackbar indefinitely. | | `static final int` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#LENGTH_LONG() = 0` Show the Snackbar for a long period of time. | | `static final int` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#LENGTH_SHORT() = -1` Show the Snackbar for a short period of time. | |

| ### Inherited fields |
|---|
| From [com.google.android.material.snackbar.BaseTransientBottomBar](https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar) |---|---| | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar.Behavior` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#behavior()` | | `final Context` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#context()` | | `final https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar.SnackbarBaseLayout` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#view()` | |

| ### Inherited methods |
|---|
| From [com.google.android.material.snackbar.BaseTransientBottomBar](https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar) |---|---| | `B` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#addCallback(com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback<B>)(https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar.BaseCallback<B> callback)` Adds the specified callback to the list of callbacks that will be notified of transient bottom bar events. | | `void` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#dispatchDismiss(int)(int event)` | | `View` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#getAnchorView()()` Returns the anchor view for this `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`. | | `int` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#getAnimationMode()()` Returns the animation mode. | | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar.Behavior` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#getBehavior()()` Return the behavior. | | `Context` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#getContext()()` Returns the `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`'s context. | | `https://developer.android.com/reference/com/google/android/material/behavior/SwipeDismissBehavior<View>` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#getNewBehavior()()` | | `int` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#getSnackbarBaseLayoutResId()()` | | `View` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#getView()()` Returns the `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`'s view. | | `boolean` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#hasSnackbarStyleAttr()()` `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar`s should still work with AppCompat themes, which don't specify a ` snackbarStyle`. | | `boolean` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#isAnchorViewLayoutListenerEnabled()()` Returns whether the anchor view layout listener is enabled. | | `boolean` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#isGestureInsetBottomIgnored()()` Returns whether this bottom bar should adjust it's position based on the system gesture area on Android Q and above. | | `boolean` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#isShownOrQueued()()` Returns whether this `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar` is currently being shown, or is queued to be shown next. | | `B` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#removeCallback(com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback<B>)(https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar.BaseCallback<B> callback)` Removes the specified callback from the list of callbacks that will be notified of transient bottom bar events. | | `B` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#setAnchorView(int)(int anchorViewId)` Sets the view the `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar` should be anchored above by id. | | `B` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#setAnchorView(View)(View anchorView)` Sets the view the `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar` should be anchored above. | | `void` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#setAnchorViewLayoutListenerEnabled(boolean)( boolean anchorViewLayoutListenerEnabled )` Sets whether the anchor view layout listener is enabled. | | `B` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#setAnimationMode(int)(int animationMode)` Sets the animation mode. | | `B` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#setBehavior(com.google.android.material.snackbar.BaseTransientBottomBar.Behavior)(https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar.Behavior behavior)` Sets the `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar.Behavior` to be used in this `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`. | | `B` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#setDuration(int)(int duration)` Set how long to show the view for. | | `B` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#setGestureInsetBottomIgnored(boolean)(boolean gestureInsetBottomIgnored)` Sets whether this bottom bar should adjust it's position based on the system gesture area on Android Q and above. | |

## Public methods

### dismiss

```
public void dismiss()
```

Dismiss the `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`.

### getDuration

```
public int getDuration()
```

Return the duration.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#setDuration(int)` |   |

### isShown

```
public boolean isShown()
```

Return whether this `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar` is currently being shown.

### make

```
public static Snackbar make(View view, int resId, int duration)
```

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.

| Parameters |
|---|---|
| `View view` | The view to find a parent from. |
| `int resId` | The resource id of the string resource to use. Can be formatted text. |
| `int duration` | How long to display the message. Can be `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#LENGTH_SHORT()`, `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#LENGTH_LONG()`, `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#LENGTH_INDEFINITE()`, or a custom duration in milliseconds. |

### make

```
public static Snackbar make(View view, CharSequence text, int duration)
```

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.

| Parameters |
|---|---|
| `View view` | The view to find a parent from. This view is also used to find the anchor view when calling `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#setAnchorView(int)`. |
| `https://developer.android.com/reference/java/lang/CharSequence text` | The text to show. Can be formatted text. |
| `int duration` | How long to display the message. Can be `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#LENGTH_SHORT()`, `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#LENGTH_LONG()`, `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#LENGTH_INDEFINITE()`, or a custom duration in milliseconds. |

### make

```
public static Snackbar make(Context context, View view, CharSequence text, int duration)
```

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.

| Parameters |
|---|---|
| `Context context` | The context to use to create the Snackbar view. |
| `View view` | The view to find a parent from. This view is also used to find the anchor view when calling `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#setAnchorView(int)`. |
| `https://developer.android.com/reference/java/lang/CharSequence text` | The text to show. Can be formatted text. |
| `int duration` | How long to display the message. Can be `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#LENGTH_SHORT()`, `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#LENGTH_LONG()`, `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#LENGTH_INDEFINITE()`, or a custom duration in milliseconds. |

### setAction

```
public Snackbar setAction(int resId, OnClickListener listener)
```

Set the action to be displayed in this `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`.

| Parameters |
|---|---|
| `int resId` | String resource to display for the action |
| `OnClickListener listener` | callback to be invoked when the action is clicked |

### setAction

```
public Snackbar setAction(CharSequence text, OnClickListener listener)
```

Set the action to be displayed in this `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence text` | Text to display for the action |
| `OnClickListener listener` | callback to be invoked when the action is clicked |

### setActionTextColor

```
public Snackbar setActionTextColor(int color)
```

Sets the text color of the action specified in `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setAction(java.lang.CharSequence,View.OnClickListener)`.

### setActionTextColor

```
public Snackbar setActionTextColor(ColorStateList colors)
```

Sets the text color of the action specified in `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setAction(java.lang.CharSequence,View.OnClickListener)`.

### setBackgroundTint

```
public Snackbar setBackgroundTint(int color)
```

Sets the tint color of the background Drawable.

### setBackgroundTintList

```
public Snackbar setBackgroundTintList(ColorStateList colorStateList)
```

Sets the tint color state list of the background Drawable.

### setBackgroundTintMode

```
public Snackbar setBackgroundTintMode(Mode mode)
```

### setCallback

```
public Snackbar [setCallback](https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setCallback(com.google.android.material.snackbar.Snackbar.Callback))(Snackbar.Callback callback)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#addCallback(com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback<B>)`

Set a callback to be called when this the visibility of this `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` changes. Note that this method is deprecated and you should use `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#addCallback(com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback<B>)` to add a callback and `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#removeCallback(com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback<B>)` to remove a registered callback.

| Parameters |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar.Callback callback` | Callback to notify when transient bottom bar events occur. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar.Callback` |   |
| `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#addCallback(com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback<B>)` |   |
| `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#removeCallback(com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback<B>)` |   |

### setCloseIconDrawable

```
public Snackbar setCloseIconDrawable(Drawable icon)
```

Set the drawable used for the optional close icon.

| Parameters |
|---|---|
| `Drawable icon` | the drawable for the close icon |

### setCloseIconResource

```
public Snackbar setCloseIconResource(int iconResourceId)
```

Set the drawable resource used for the optional close icon.

| Parameters |
|---|---|
| `int iconResourceId` | the drawable resource id for the close icon |

### setCloseIconTint

```
public Snackbar setCloseIconTint(int tint)
```

Set the tint color of the optional close icon.

| Parameters |
|---|---|
| `int tint` | the tint color to be used for the close icon |

### setCloseIconTintList

```
public Snackbar setCloseIconTintList(ColorStateList tintList)
```

Set the tint list of the optional close icon.

| Parameters |
|---|---|
| `ColorStateList tintList` | the tint list to be used for the close icon |

### setCloseIconVisible

```
public Snackbar setCloseIconVisible(boolean visible)
```

Show an optional close icon at the end of the snackbar.

The close icon is set to `View.GONE` by default. Setting the icon to visible will show the icon at the end of the layout and automatically dismiss the snackbar when clicked. This method and other related closeIcon setters can only be used within the context of a Material 3 or greater theme.

When using a close icon, please consider setting the snackbar's duration to `
Snackbar.LENGTH_INDEFINITE`.

This method will automatically remove any end padding from the snackbar layout to properly align the close icon button. To manually set end padding, use `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#getView()` and call setPaddingRelative before showing the snackbar.

| Parameters |
|---|---|
| `boolean visible` | true to make the close icon visible |

### setMaxInlineActionWidth

```
public Snackbar setMaxInlineActionWidth(int width)
```

Sets the max width of the action to be in the same line as the message. If the width is exceeded the action would go to the next line.

### setText

```
public Snackbar setText(CharSequence message)
```

Update the text in this `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence message` | The new text for this `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`. |

### setText

```
public Snackbar setText(int resId)
```

Update the text in this `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar`.

| Parameters |
|---|---|
| `int resId` | The new text for this `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`. |

### setTextColor

```
public Snackbar setTextColor(int color)
```

Sets the text color of the message specified in `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setText(java.lang.CharSequence)` and `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setText(int)`.

### setTextColor

```
public Snackbar setTextColor(ColorStateList colors)
```

Sets the text color of the message specified in `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setText(java.lang.CharSequence)` and `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setText(int)`.

### setTextMaxLines

```
public Snackbar setTextMaxLines(int maxLines)
```

Sets the max line count of the message specified in `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setText(java.lang.CharSequence)` and `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#setText(int)`.

### show

```
public void show()
```

Show the `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`.

## Protected methods

### hasSnackbarButtonStyleAttr

```
protected static boolean [hasSnackbarButtonStyleAttr](https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar#hasSnackbarButtonStyleAttr(Context))(Context context)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> This is for backward compatibility with AppCompat themes.

`https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar`s should still work with AppCompat themes, which don't specify a `
snackbarButtonStyle`. This method helps to check if a valid `snackbarButtonStyle` is set within the current context, so that we know whether we can use the attribute.