# BaseTransientBottomBar

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

*** ** * ** ***


```
public abstract class BaseTransientBottomBar<B extends BaseTransientBottomBar<B>>
```

<br />

Known direct subclasses [Snackbar](https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar)

|---|---|
| `https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar` | Snackbars provide lightweight feedback about an operation. |

*** ** * ** ***

Base class for lightweight transient bars that are displayed along the bottom edge of the application window.

| Parameters |
|---|---|
| `<B extends https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar<B>>` | The transient bottom bar subclass. |

## Summary

| ### Nested types |
|---|
| `public abstract class https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar.BaseCallback<B>` Base class for `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar` callbacks. |
| `public class https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar.Behavior extends https://developer.android.com/reference/com/google/android/material/behavior/SwipeDismissBehavior` Behavior for `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`. |
| `public interface https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar.ContentViewCallback extends https://developer.android.com/reference/com/google/android/material/snackbar/ContentViewCallback` **This interface is deprecated.** Use `https://developer.android.com/reference/com/google/android/material/snackbar/ContentViewCallback` instead. <br /> |

| ### Constants |
|---|---|
| `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. |

| ### Public fields |
|---|---|
| `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()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#duration()` |

| ### Protected fields |
|---|---|
| `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()` |

| ### Protected constructors |
|---|
| `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#BaseTransientBottomBar(ViewGroup,View,com.google.android.material.snackbar.ContentViewCallback)( ViewGroup parent, View content, https://developer.android.com/reference/com/google/android/material/snackbar/ContentViewCallback contentViewCallback )` Constructor for the transient bottom bar. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#BaseTransientBottomBar(Context,ViewGroup,View,com.google.android.material.snackbar.ContentViewCallback)( Context context, ViewGroup parent, View content, https://developer.android.com/reference/com/google/android/material/snackbar/ContentViewCallback contentViewCallback )` |

| ### Public methods |
|---|---|
| `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#dismiss()()` Dismiss the `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`. |
| `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. |
| `int` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#getDuration()()` Return the duration. |
| `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#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#isShown()()` Return whether this `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar` is currently being shown. |
| `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. |
| `void` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#show()()` Show the `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`. |

| ### Protected methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#dispatchDismiss(int)(int event)` |
| `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()()` |
| `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`. |

## Constants

### ANIMATION_MODE_FADE

```
public static final int ANIMATION_MODE_FADE = 1
```

Animation mode that corresponds to the fade in and out animations.

### ANIMATION_MODE_SLIDE

```
public static final int ANIMATION_MODE_SLIDE = 0
```

Animation mode that corresponds to the slide in and out animations.

### LENGTH_INDEFINITE

```
public static final int LENGTH_INDEFINITE = -2
```

Show the Snackbar indefinitely. This means that the Snackbar will be displayed from the time that is `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#show()` until either it is dismissed, or another Snackbar is shown.

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

### LENGTH_LONG

```
public static final int LENGTH_LONG = 0
```

Show the Snackbar for a long period of time.

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

### LENGTH_SHORT

```
public static final int LENGTH_SHORT = -1
```

Show the Snackbar for a short period of time.

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

## Public fields

### behavior

```
public BaseTransientBottomBar.Behavior behavior
```

### context

```
public final Context context
```

### duration

```
public int duration
```

## Protected fields

### view

```
protected final BaseTransientBottomBar.SnackbarBaseLayout view
```

## Protected constructors

### BaseTransientBottomBar

```
protected BaseTransientBottomBar(
    ViewGroup parent,
    View content,
    ContentViewCallback contentViewCallback
)
```

Constructor for the transient bottom bar.

Uses Context from `parent`.

| Parameters |
|---|---|
| `ViewGroup parent` | The parent for this transient bottom bar. |
| `View content` | The content view for this transient bottom bar. |
| `https://developer.android.com/reference/com/google/android/material/snackbar/ContentViewCallback contentViewCallback` | The content view callback for this transient bottom bar. |

### BaseTransientBottomBar

```
protected BaseTransientBottomBar(
    Context context,
    ViewGroup parent,
    View content,
    ContentViewCallback contentViewCallback
)
```

## Public methods

### addCallback

```
public B addCallback(BaseTransientBottomBar.BaseCallback<B> callback)
```

Adds the specified callback to the list of callbacks that will be notified of transient bottom bar events.

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

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

### dismiss

```
public void dismiss()
```

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

### getAnchorView

```
public View getAnchorView()
```

Returns the anchor view for this `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`.

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

### getAnimationMode

```
public int getAnimationMode()
```

Returns the animation mode.

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

### getBehavior

```
public BaseTransientBottomBar.Behavior getBehavior()
```

Return the behavior.

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

### getContext

```
public Context getContext()
```

Returns the `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`'s context.

### getDuration

```
public int getDuration()
```

Return the duration.

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

### getView

```
public View getView()
```

Returns the `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar`'s view.

### isAnchorViewLayoutListenerEnabled

```
public boolean isAnchorViewLayoutListenerEnabled()
```

Returns whether the anchor view layout listener is enabled.

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

### isGestureInsetBottomIgnored

```
public boolean isGestureInsetBottomIgnored()
```

Returns whether this bottom bar should adjust it's position based on the system gesture area on Android Q and above. See `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#setGestureInsetBottomIgnored(boolean)`.

### isShown

```
public boolean isShown()
```

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

### isShownOrQueued

```
public boolean 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.

### removeCallback

```
public B removeCallback(BaseTransientBottomBar.BaseCallback<B> callback)
```

Removes the specified callback from the list of callbacks that will be notified of transient bottom bar events.

| Parameters |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar.BaseCallback<B> callback` | Callback to remove from being notified of transient bottom bar events |

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

### setAnchorView

```
public B setAnchorView(int anchorViewId)
```

Sets the view the `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar` should be anchored above by id.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the anchor view is not found. |

### setAnchorView

```
public B setAnchorView(View anchorView)
```

Sets the view the `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar` should be anchored above.

### setAnchorViewLayoutListenerEnabled

```
public void setAnchorViewLayoutListenerEnabled(
    boolean anchorViewLayoutListenerEnabled
)
```

Sets whether the anchor view layout listener is enabled. If enabled, the `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar` will recalculate and update its position when the position of the anchor view is changed.

### setAnimationMode

```
public B setAnimationMode(int animationMode)
```

Sets the animation mode.

| Parameters |
|---|---|
| `int animationMode` | of `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#ANIMATION_MODE_SLIDE()` or `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar#ANIMATION_MODE_FADE()`. |

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

### setBehavior

```
public B setBehavior(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`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar.Behavior behavior` | `https://developer.android.com/reference/com/google/android/material/snackbar/BaseTransientBottomBar.Behavior` to be applied. |

### setDuration

```
public B setDuration(int duration)
```

Set how long to show the view for.

| Parameters |
|---|---|
| `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. |

### setGestureInsetBottomIgnored

```
public B setGestureInsetBottomIgnored(boolean gestureInsetBottomIgnored)
```

Sets whether this bottom bar should adjust it's position based on the system gesture area on Android Q and above.

Note: the bottom bar will only adjust it's position if it is dismissable via swipe (because that would cause a gesture conflict), gesture navigation is enabled, and this `
gestureInsetBottomIgnored` flag is false.

### show

```
public void show()
```

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

## Protected methods

### dispatchDismiss

```
protected void dispatchDismiss(int event)
```

### getNewBehavior

```
protected SwipeDismissBehavior<View> getNewBehavior()
```

### getSnackbarBaseLayoutResId

```
protected int getSnackbarBaseLayoutResId()
```

### hasSnackbarStyleAttr

```
protected boolean 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`. This method helps to check if a valid `snackbarStyle` is set within the current context, so that we know whether we can use the attribute.