Google se compromete a impulsar la igualdad racial para las comunidades afrodescendientes. Obtén información al respecto.

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 ActionBar.Tab!

Create and return a new Tab.

abstract Unit

Remove all tabs from the action bar and deselect the current tab.

abstract Unit

Remove a menu visibility listener.

abstract Unit

Remove a tab from the action bar.

abstract Unit
removeTabAt(position: Int)

Remove a tab from the action bar.

abstract Unit

Select the specified tab.

abstract Unit

Set the ActionBar's background.

abstract Unit

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

Set the action bar into custom navigation mode, supplying a view for custom navigation.

abstract Unit

Set whether home should be displayed as an "up" affordance.

abstract Unit

Set display options.

abstract Unit
setDisplayOptions(options: Int, mask: Int)

Set selected display options.

abstract Unit

Set whether a custom view should be displayed, if set.

abstract Unit

Set whether to include the application home affordance in the action bar.

abstract Unit

Set whether an activity title/subtitle should be displayed.

abstract Unit

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

Set an alternate description for the Home/Up action, when enabled.

open Unit

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 DISPLAY_HOME_AS_UP is enabled.

open Unit
setHomeAsUpIndicator(@DrawableRes resId: Int)

Set an alternate drawable to display next to the icon/logo/title when DISPLAY_HOME_AS_UP is enabled.

open Unit

Enable or disable the "home" button in the corner of the action bar.

abstract Unit
setIcon(@DrawableRes resId: Int)

Set the icon to display in the 'home' section of the action bar.

abstract Unit
setIcon(icon: Drawable!)

Set the icon to display in the 'home' section of the action bar.

abstract Unit

Set the adapter and navigation callback for list navigation mode.

abstract Unit
setLogo(@DrawableRes resId: Int)

Set the logo to display in the 'home' section of the action bar.

abstract Unit
setLogo(: Drawable!)

Set the logo to display in the 'home' section of the action bar.

abstract Unit

Set the current navigation mode.

abstract Unit

Set the selected navigation item in list or tabbed navigation modes.

open Unit

Set the ActionBar's split background.

open Unit

Set the ActionBar's stacked background.

abstract Unit

Set the action bar's subtitle.

abstract Unit
setSubtitle(resId: Int)

Set the action bar's subtitle.

abstract Unit

Set the action bar's title.

abstract Unit
setTitle(@StringRes resId: Int)

Set the action bar's title.

abstract Unit

Show the ActionBar if it is not currently showing.

Constants

DISPLAY_HOME_AS_UP

static val DISPLAY_HOME_AS_UP: Int

Display the 'home' element such that it appears as an 'up' affordance. e.g. show an arrow to the left indicating the action that will be taken. Set this flag if selecting the 'home' button in the action bar to return up by a single level in your UI rather than back to the top level or front page.

Setting this option will implicitly enable interaction with the home/up button. See setHomeButtonEnabled(boolean).

Value: android.app.ActionBar.DISPLAY_HOME_AS_UP

DISPLAY_SHOW_CUSTOM

static val DISPLAY_SHOW_CUSTOM: Int

Show the custom view if one has been set.

Value: android.app.ActionBar.DISPLAY_SHOW_CUSTOM

DISPLAY_SHOW_HOME

static val DISPLAY_SHOW_HOME: Int

Show 'home' elements in this action bar, leaving more space for other navigation elements. This includes logo and icon.

Value: android.app.ActionBar.DISPLAY_SHOW_HOME

DISPLAY_SHOW_TITLE

static val DISPLAY_SHOW_TITLE: Int

Show the activity title and subtitle, if present.

Value: android.app.ActionBar.DISPLAY_SHOW_TITLE
static val DISPLAY_USE_LOGO: Int

Use logo instead of icon if available. This flag will cause appropriate navigation modes to use a wider logo in place of the standard icon.

Value: android.app.ActionBar.DISPLAY_USE_LOGO
static val NAVIGATION_MODE_LIST: Int

Deprecated: Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead.

List navigation mode. Instead of static title text this mode presents a list menu for navigation within the activity. e.g. this might be presented to the user as a dropdown list.

Value: 1
static val NAVIGATION_MODE_STANDARD: Int

Deprecated: Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead.

Standard navigation mode. Consists of either a logo or icon and title text with an optional subtitle. Clicking any of these elements will dispatch onOptionsItemSelected to the host Activity with a MenuItem with item ID android.R.id.home.

Value: 0
static val NAVIGATION_MODE_TABS: Int

Deprecated: Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead.

Tab navigation mode. Instead of static title text this mode presents a series of tabs for navigation within the activity.

Value: 2

Public constructors

<init>

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.

Public methods

addOnMenuVisibilityListener

abstract fun addOnMenuVisibilityListener(listener: ActionBar.OnMenuVisibilityListener!): Unit

Add a listener that will respond to menu visibility change events.

Parameters
listener ActionBar.OnMenuVisibilityListener!: The new listener to add

addTab

abstract fun addTab(tab: ActionBar.Tab!): Unit

Deprecated: Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead.

Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. If this is the first tab to be added it will become the selected tab.

Parameters
tab ActionBar.Tab!: Tab to add

addTab

abstract fun addTab(
    tab: ActionBar.Tab