ActionBar
abstract class ActionBar
kotlin.Any | |
↳ | androidx.appcompat.app.ActionBar |
A primary toolbar within the activity that may display the activity title, application-level navigation affordances, and other interactive items.
The action bar appears at the top of an activity's window when the activity uses the AppCompat's AppCompat
theme (or one of its descendant themes). You may otherwise add the action bar by calling
or by declaring it in a custom theme with the windowActionBar
property.
The action bar may be represented by any Toolbar widget within the application layout. The application may signal to the Activity which Toolbar should be treated as the Activity's action bar. Activities that use this feature should use one of the supplied .NoActionBar
themes, set the windowActionBar
attribute to false
or otherwise not request the window feature.
If your activity has an options menu, you can make select items accessible directly from the action bar as "action items". You can also modify various characteristics of the action bar or remove it completely.
The navigation button (formerly "Home") takes over the space previously occupied by the application icon. Apps wishing to express a stronger branding should use their brand colors heavily in the action bar and other application chrome or use a logo
in place of their standard title text.
From your activity, you can retrieve an instance of ActionBar
by calling
getSupportActionBar()}.
In some cases, the action bar may be overlayed by another bar that enables contextual actions, using an ActionMode
. For example, when the user selects one or more items in your activity, you can enable an action mode that offers actions specific to the selected items, with a UI that temporarily replaces the action bar. Although the UI may occupy the same space, the ActionMode
APIs are distinct and independent from those for ActionBar
.
Summary
Nested classes | |
---|---|
open |
Per-child layout information associated with action bar custom views. |
abstract |
Listener for receiving events when action bar menus are shown or hidden. |
abstract |
Listener interface for ActionBar navigation events. |
abstract |
A tab in the action bar. |
abstract |
Callback interface invoked when a tab is focused, unfocused, added, or removed. |
Constants | |
---|---|
static Int |
Display the 'home' element such that it appears as an 'up' affordance. |
static Int |
Show the custom view if one has been set. |
static Int |
Show 'home' elements in this action bar, leaving more space for other navigation elements. |
static Int |
Show the activity title and subtitle, if present. |
static Int |
Use logo instead of icon if available. |
static Int |
List navigation mode. |
static Int |
Standard navigation mode. |
static Int |
Tab navigation mode. |
Public constructors | |
---|---|
<init>() A primary toolbar within the activity that may display the activity title, application-level navigation affordances, and other interactive items. |
Public methods | |
---|---|
abstract Unit |
Add a listener that will respond to menu visibility change events. |
abstract Unit |
addTab(tab: ActionBar.Tab!) Add a tab for use in tabbed navigation mode. |
abstract Unit |
addTab(tab: ActionBar.Tab!, setSelected: Boolean) Add a tab for use in tabbed navigation mode. |
abstract Unit |
addTab(tab: ActionBar.Tab!, position: Int) Add a tab for use in tabbed navigation mode. |
abstract Unit |
addTab(tab: ActionBar.Tab!, position: Int, setSelected: Boolean) Add a tab for use in tabbed navigation mode. |
abstract View! | |
abstract Int | |
open Float |
Get the Z-axis elevation of the action bar in pixels. |
abstract Int |
Retrieve the current height of the ActionBar. |
open Int |
Return the current vertical offset of the action bar. |
abstract Int |
Get the number of navigation items present in the current navigation mode. |
abstract Int |
Returns the current navigation mode. |
abstract Int |
Get the position of the selected navigation item in list or tabbed navigation modes. |
abstract ActionBar.Tab? |
Returns the currently selected tab if in tabbed navigation mode and there is at least one tab present. |
abstract CharSequence? |
Returns the current ActionBar subtitle in standard mode. |
abstract ActionBar.Tab! |
Returns the tab at the specified index. |
abstract Int |
Returns the number of tabs currently registered with the action bar. |
open Context! |
Returns a |
abstract CharSequence? |
getTitle() Returns the current ActionBar title in standard mode. |
abstract Unit |
hide() Hide the ActionBar if it is currently showing. |
open Boolean |
Return whether the action bar is configured to scroll out of sight along with a |
abstract Boolean | |
abstract ActionBar.Tab! |
newTab() Create and return a new |
abstract Unit |
Remove all tabs from the action bar and deselect the current tab. |
abstract Unit |
Remove a menu visibility listener. |
abstract Unit |
removeTab(tab: ActionBar.Tab!) Remove a tab from the action bar. |
abstract Unit |
removeTabAt(position: Int) Remove a tab from the action bar. |
abstract Unit |
selectTab(tab: ActionBar.Tab!) Select the specified tab. |
abstract Unit |
setBackgroundDrawable(@Nullable d: Drawable?) Set the ActionBar's background. |
abstract Unit |
setCustomView(view: View!) Set the action bar into custom navigation mode, supplying a view for custom navigation. |
abstract Unit |
setCustomView(view: View!, layoutParams: ActionBar.LayoutParams!) Set the action bar into custom navigation mode, supplying a view for custom navigation. |
abstract Unit |
setCustomView(resId: Int) Set the action bar into custom navigation mode, supplying a view for custom navigation. |
abstract Unit |
setDisplayHomeAsUpEnabled(showHomeAsUp: Boolean) Set whether home should be displayed as an "up" affordance. |
abstract Unit |
setDisplayOptions(options: Int) Set display options. |
abstract Unit |
setDisplayOptions(options: Int, mask: Int) Set selected display options. |
abstract Unit |
setDisplayShowCustomEnabled(showCustom: Boolean) Set whether a custom view should be displayed, if set. |
abstract Unit |
setDisplayShowHomeEnabled(showHome: Boolean) Set whether to include the application home affordance in the action bar. |
abstract Unit |
setDisplayShowTitleEnabled(showTitle: Boolean) Set whether an activity title/subtitle should be displayed. |
abstract Unit |
setDisplayUseLogoEnabled(useLogo: Boolean) Set whether to display the activity logo rather than the activity icon. |
open Unit |
setElevation(elevation: Float) Set the Z-axis elevation of the action bar in pixels. |
open Unit |
setHideOffset(offset: Int) Set the current hide offset of the action bar. |
open Unit |
setHideOnContentScrollEnabled(hideOnContentScroll: Boolean) Enable hiding the action bar on content scroll. |
open Unit |
setHomeActionContentDescription(@Nullable description: CharSequence?) Set an alternate description for the Home/Up action, when enabled. |
open Unit |
setHomeActionContentDescription(@StringRes resId: Int) Set an alternate description for the Home/Up action, when enabled. |
open Unit |
setHomeAsUpIndicator(@Nullable indicator: Drawable?) Set an alternate drawable to display next to the icon/logo/title when |
open Unit |
setHomeAsUpIndicator(@DrawableRes resId: Int) Set an alternate drawable to display next to the icon/logo/title when |
open Unit |
setHomeButtonEnabled(enabled: Boolean) Enable or disable the "home" button in the corner of the action bar. |
abstract Unit |
Set the icon to display in the 'home' section of the action bar. |
abstract Unit |
Set the icon to display in the 'home' section of the action bar. |
abstract |