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>> |
![]() |
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 |
class |
BaseTransientBottomBar.Behavior
Behavior for |
interface |
BaseTransientBottomBar.ContentViewCallback
This interface is deprecated.
Use |
Constants | |
---|---|
int |
ANIMATION_MODE_FADE
Animation mode that corresponds to the fade in and out animations. |
int |
ANIMATION_MODE_SLIDE
Animation mode that corresponds to the slide in and out animations. |
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 |
View
|
getAnchorView()
Returns the anchor view for this |
int
|
getAnimationMode()
Returns the BaseTransientBottomBar.AnimationMode. |
BaseTransientBottomBar.Behavior
|
getBehavior()
Return the behavior. |
Context
|
getContext()
Returns the |
int
|
getDuration()
Return the duration. |
View
|
getView()
Returns the |
boolean
|
isGestureInsetBottomIgnored()
Returns whether this bottom bar should adjust it's position based on the system gesture area on Android Q and above. |
boolean
|
isShown()
Return whether this |
boolean
|
isShownOrQueued()
Returns whether this |
B
|
removeCallback(BaseCallback<B> callback)
Removes the specified callback from the list of callbacks that will be notified of transient bottom bar events. |
B
|
setAnchorView(View anchorView)
Sets the view the |
B
|
setAnchorView(int anchorViewId)
Sets the id of the view the |
B
|
setAnimationMode(int animationMode)
Sets the BaseTransientBottomBar.AnimationMode. |
B
|
setBehavior(BaseTransientBottomBar.Behavior behavior)
Sets the |
B
|
setDuration(int duration)
Set how long to show the view for. |
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. |
void
|
show()
Show the |
Protected methods | |
---|---|
void
|
dispatchDismiss(int event)
|
SwipeDismissBehavior<? extends View>
|
getNewBehavior()
|
int
|
getSnackbarBaseLayoutResId()
|
boolean
|
hasSnackbarStyleAttr()
|
Inherited methods | |
---|---|
![]()
java.lang.Object
|
Constants
ANIMATION_MODE_FADE
int ANIMATION_MODE_FADE
Animation mode that corresponds to the fade in and out animations.
Constant Value: 1 (0x00000001)
ANIMATION_MODE_SLIDE
int ANIMATION_MODE_SLIDE
Animation mode that corresponds to the slide in and out animations.
Constant Value: 0 (0x00000000)
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 |
See also:
getAnchorView
View getAnchorView ()
Returns the anchor view for this BaseTransientBottomBar
.
Returns | |
---|---|
View |
See also:
getAnimationMode
int getAnimationMode ()
Returns the BaseTransientBottomBar.AnimationMode.
Returns | |
---|---|
int |
getBehavior
BaseTransientBottomBar.Behavior getBehavior ()
Return the behavior.
Returns | |
---|---|
BaseTransientBottomBar.Behavior |
isGestureInsetBottomIgnored
boolean isGestureInsetBottomIgnored ()
Returns whether this bottom bar should adjust it's position based on the system gesture area on
Android Q and above. See setGestureInsetBottomIgnored(boolean)
.
Returns | |
---|---|
boolean |
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 |
See also:
setAnchorView
B setAnchorView (View anchorView)
Sets the view the BaseTransientBottomBar
should be anchored above.
Parameters | |
---|---|
anchorView |
View |
Returns | |
---|---|
B |
setAnchorView
B setAnchorView (int anchorViewId)
Sets the id of the view the BaseTransientBottomBar
should be anchored above.
Parameters | |
---|---|
anchorViewId |
int |
Returns | |
---|---|
B |
Throws | |
---|---|
IllegalArgumentException |
if the anchor view is not found. |
setAnimationMode
B setAnimationMode (int animationMode)
Sets the BaseTransientBottomBar.AnimationMode.
Parameters | |
---|---|
animationMode |
int |
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 |
setGestureInsetBottomIgnored
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.
Parameters | |
---|---|
gestureInsetBottomIgnored |
boolean |
Returns | |
---|---|
B |
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 ()
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.
Returns | |
---|---|
boolean |
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.