lightbulb_outline Please take our October 2018 developer survey. Start survey

BaseTransientBottomBar

public abstract class BaseTransientBottomBar
extends Object

java.lang.Object
   ↳ com.google.android.material.snackbar.BaseTransientBottomBar<B extends com.google.android.material.snackbar.BaseTransientBottomBar<B>>
Known Direct Subclasses


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

Summary

Nested classes

class BaseTransientBottomBar.BaseCallback<B>

Base class for BaseTransientBottomBar callbacks. 

class BaseTransientBottomBar.Behavior

Behavior for BaseTransientBottomBar

interface BaseTransientBottomBar.ContentViewCallback

This interface is deprecated. Use ContentViewCallback instead.  

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.

Fields

protected final BaseTransientBottomBar.SnackbarBaseLayout view

Protected constructors

BaseTransientBottomBar(ViewGroup parent, View content, ContentViewCallback contentViewCallback)

Constructor for the transient bottom bar.

Public methods

B addCallback(BaseCallback<B> callback)

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

void dismiss()

Dismiss the BaseTransientBottomBar.

BaseTransientBottomBar.Behavior getBehavior()

Return the behavior.

Context getContext()

Returns the BaseTransientBottomBar's context.

int getDuration()

Return the duration.

View getView()

Returns the BaseTransientBottomBar's view.

boolean isShown()

Return whether this BaseTransientBottomBar is currently being shown.

boolean isShownOrQueued()

Returns whether this BaseTransientBottomBar is currently being shown, or is queued to be shown next.

B removeCallback(BaseCallback<B> callback)

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

B setBehavior(BaseTransientBottomBar.Behavior behavior)

Sets the BaseTransientBottomBar.Behavior to be used in this BaseTransientBottomBar.

B setDuration(int duration)

Set how long to show the view for.

void show()

Show the BaseTransientBottomBar.

Protected methods

void dispatchDismiss(int event)
SwipeDismissBehavior<? extends View> getNewBehavior()
int getSnackbarBaseLayoutResId()
boolean hasSnackbarStyleAttr()

Snackbars should still work with AppCompat themes, which don't specify a snackbarStyle.

Inherited methods

From class java.lang.Object

Constants

LENGTH_INDEFINITE

int LENGTH_INDEFINITE

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.

See also:

Constant Value: -2 (0xfffffffe)

LENGTH_LONG

int LENGTH_LONG

Show the Snackbar for a long period of time.

See also:

Constant Value: 0 (0x00000000)

LENGTH_SHORT

int LENGTH_SHORT

Show the Snackbar for a short period of time.

See also:

Constant Value: -1 (0xffffffff)

Fields

Protected constructors

BaseTransientBottomBar

BaseTransientBottomBar (ViewGroup parent, 
                View content, 
                ContentViewCallback contentViewCallback)

Constructor for the transient bottom bar.

Parameters
parent ViewGroup: The parent for this transient bottom bar.

content View: The content view for this transient bottom bar.

contentViewCallback ContentViewCallback: The content view callback for this transient bottom bar.

Public methods

addCallback

B addCallback (BaseCallback<B> callback)

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

Parameters
callback BaseCallback: Callback to notify when transient bottom bar events occur.

Returns
B

dismiss

void dismiss ()

Dismiss the BaseTransientBottomBar.

getContext

Context getContext ()

Returns the BaseTransientBottomBar's context.

Returns
Context

getDuration

int getDuration ()

Return the duration.

Returns
int

See also:

getView

View getView ()

Returns the BaseTransientBottomBar's view.

Returns
View

isShown

boolean isShown ()

Return whether this BaseTransientBottomBar is currently being shown.

Returns
boolean

isShownOrQueued

boolean isShownOrQueued ()

Returns whether this BaseTransientBottomBar is currently being shown, or is queued to be shown next.

Returns
boolean

removeCallback

B removeCallback (BaseCallback<B> callback)

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

Parameters
callback BaseCallback: Callback to remove from being notified of transient bottom bar events

Returns
B

setBehavior

B setBehavior (BaseTransientBottomBar.Behavior behavior)

Sets the BaseTransientBottomBar.Behavior to be used in this BaseTransientBottomBar.

Parameters
behavior BaseTransientBottomBar.Behavior: BaseTransientBottomBar.Behavior to be applied.

Returns
B

setDuration

B setDuration (int duration)

Set how long to show the view for.

Parameters
duration int: How long to display the message. Can be LENGTH_SHORT, LENGTH_LONG, LENGTH_INDEFINITE, or a custom duration in milliseconds.

Returns
B

show

void show ()

Show the BaseTransientBottomBar.

Protected methods

dispatchDismiss

void dispatchDismiss (int event)

Parameters
event int

getNewBehavior

SwipeDismissBehavior<? extends View> getNewBehavior ()

Returns
SwipeDismissBehavior<? extends View>

getSnackbarBaseLayoutResId

int getSnackbarBaseLayoutResId ()

Returns
int

hasSnackbarStyleAttr

boolean hasSnackbarStyleAttr ()

Snackbars 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.

Returns
boolean