Android 12 Developer Preview is here! Try it out, and give us your feedback!

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

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

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!
getTabAt(index: Int)

Returns the tab at the specified index.

abstract Int

Returns the number of tabs currently registered with the action bar.

open Context!

Returns a Context with an appropriate theme for creating views that will appear in the action bar.

abstract CharSequence?

Returns the current ActionBar title in standard mode.

abstract Unit

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 nested scrolling child.

abstract Boolean

abstract