It's happening now, watch the livestream.

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 R.style#Theme_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 R.styleable#AppCompatTheme_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 R.styleable#AppCompatTheme_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

DISPLAY_USE_LOGO

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

NAVIGATION_MODE_LIST

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

NAVIGATION_MODE_STANDARD

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

NAVIGATION_MODE_TABS

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 R.style#Theme_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 R.styleable#AppCompatTheme_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 R.styleable#AppCompatTheme_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!, setSelected: Boolean): 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.

Parameters
tab ActionBar.Tab!: Tab to add
setSelected ActionBar.Tab!: True if the added tab should become the selected tab.

addTab

abstract fun addTab(tab: ActionBar.Tab!, position: Int): 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 inserted at position. If this is the first tab to be added it will become the selected tab.

Parameters
tab ActionBar.Tab!: The tab to add
position ActionBar.Tab!: The new position of the tab

addTab

abstract fun addTab(tab: ActionBar.Tab!, position: Int, setSelected: Boolean): 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 inserted at position.

Parameters
tab ActionBar.Tab!: The tab to add
position ActionBar.Tab!: The new position of the tab
setSelected ActionBar.Tab!: True if the added tab should become the selected tab.

getCustomView

abstract fun getCustomView(): View!
Return
View!: The current custom view.

getDisplayOptions

abstract fun getDisplayOptions(): Int
Return
Int: The current set of display options.

getElevation

open fun getElevation(): Float

Get the Z-axis elevation of the action bar in pixels.

The action bar's elevation is the distance it is placed from its parent surface. Higher values are closer to the user.

Return
Float: Elevation value in pixels

getHeight

abstract fun getHeight(): Int

Retrieve the current height of the ActionBar.

Return
Int: The ActionBar's height

getHideOffset

open fun getHideOffset(): Int

Return the current vertical offset of the action bar.

The action bar's current hide offset is the distance that the action bar is currently scrolled offscreen in pixels. The valid range is 0 (fully visible) to the action bar's current measured height (fully invisible).

Return
Int: The action bar's offset toward its fully hidden state in pixels

getNavigationItemCount

abstract fun getNavigationItemCount(): Int

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

Get the number of navigation items present in the current navigation mode.

Return
Int: Number of navigation items.

getNavigationMode

abstract fun getNavigationMode(): Int

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

Returns the current navigation mode. The result will be one of:

Return
Int: The current navigation mode.

getSelectedNavigationIndex

abstract fun getSelectedNavigationIndex(): Int

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

Get the position of the selected navigation item in list or tabbed navigation modes.

Return
Int: Position of the selected item.

getSelectedTab

@Nullable abstract fun getSelectedTab(): ActionBar.Tab?

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

Returns the currently selected tab if in tabbed navigation mode and there is at least one tab present.

Return
ActionBar.Tab?: The currently selected tab or null

getSubtitle

@Nullable abstract fun getSubtitle(): CharSequence?

Returns the current ActionBar subtitle in standard mode. Returns null if getNavigationMode() would not return NAVIGATION_MODE_STANDARD.

Return
CharSequence?: The current ActionBar subtitle or null.

getTabAt

abstract fun getTabAt(index: Int): ActionBar.Tab!

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

Returns the tab at the specified index.

Parameters
index Int: Index value in the range 0-get
Return
ActionBar.Tab!:

getTabCount

abstract fun getTabCount(): Int

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

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

Return
Int: Tab count

getThemedContext

open fun getThemedContext(): Context!

Returns a Context with an appropriate theme for creating views that will appear in the action bar. If you are inflating or instantiating custom views that will appear in an action bar, you should use the Context returned by this method. (This includes adapters used for list navigation mode.) This will ensure that views contrast properly against the action bar.

Return
Context!: A themed Context for creating views

getTitle

@Nullable abstract fun getTitle(): CharSequence?

Returns the current ActionBar title in standard mode. Returns null if getNavigationMode() would not return NAVIGATION_MODE_STANDARD.

Return
CharSequence?: The current ActionBar title or null.

hide

abstract fun hide(): Unit

Hide the ActionBar if it is currently showing. If the window hosting the ActionBar does not have the feature Window#FEATURE_ACTION_BAR_OVERLAY it will resize application content to fit the new space available.

Instead of calling this function directly, you can also cause an ActionBar using the overlay feature to hide through View.SYSTEM_UI_FLAG_FULLSCREEN. Hiding the ActionBar through this system UI flag allows you to more seamlessly hide it in conjunction with other screen decorations.

isHideOnContentScrollEnabled

open fun isHideOnContentScrollEnabled(): Boolean

Return whether the action bar is configured to scroll out of sight along with a nested scrolling child.

Return
Boolean: true if hide-on-content-scroll is enabled

isShowing

abstract fun isShowing(): Boolean
Return
Boolean: true if the ActionBar is showing, false otherwise.

newTab

abstract fun newTab(): ActionBar.Tab!

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

Create and return a new Tab. This tab will not be included in the action bar until it is added.

Return
ActionBar.Tab!: A new Tab

See Also

removeAllTabs

abstract fun removeAllTabs(): Unit

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

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

removeOnMenuVisibilityListener

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

Remove a menu visibility listener. This listener will no longer receive menu visibility change events.

Parameters
listener ActionBar.OnMenuVisibilityListener!: A listener to remove that was previously added

removeTab

abstract fun removeTab(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.

Remove a tab from the action bar. If the removed tab was selected it will be deselected and another tab will be selected if present.

Parameters
tab ActionBar.Tab!: The tab to remove

removeTabAt

abstract fun removeTabAt(position: Int): Unit

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

Remove a tab from the action bar. If the removed tab was selected it will be deselected and another tab will be selected if present.

Parameters
position Int: Position of the tab to remove

selectTab

abstract fun selectTab(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.

Select the specified tab. If it is not a child of this action bar it will be added.

Note: If you want to select by index, use setSelectedNavigationItem(int).

Parameters
tab ActionBar.Tab!: Tab to select

setBackgroundDrawable

abstract fun setBackgroundDrawable(@Nullable d: Drawable?): Unit

Set the ActionBar's background. This will be used for the primary action bar.

Parameters
d Drawable?: Background drawable

setCustomView

abstract fun setCustomView(view: View!): Unit

Set the action bar into custom navigation mode, supplying a view for custom navigation. Custom navigation views appear between the application icon and any action buttons and may use any space available there. Common use cases for custom navigation views might include an auto-suggesting address bar for a browser or other navigation mechanisms that do not translate well to provided navigation modes.

Parameters
view View!: Custom navigation view to place in the ActionBar.

setCustomView

abstract fun setCustomView(view: View!, layoutParams: ActionBar.LayoutParams!): Unit

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

Custom navigation views appear between the application icon and any action buttons and may use any space available there. Common use cases for custom navigation views might include an auto-suggesting address bar for a browser or other navigation mechanisms that do not translate well to provided navigation modes.

The display option DISPLAY_SHOW_CUSTOM must be set for the custom view to be displayed.

Parameters
view View!: Custom navigation view to place in the ActionBar.
layoutParams View!: How this custom view should layout in the bar.

setCustomView

abstract fun setCustomView(resId: Int): Unit

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

Custom navigation views appear between the application icon and any action buttons and may use any space available there. Common use cases for custom navigation views might include an auto-suggesting address bar for a browser or other navigation mechanisms that do not translate well to provided navigation modes.

The display option DISPLAY_SHOW_CUSTOM must be set for the custom view to be displayed.

Parameters
resId Int: Resource ID of a layout to inflate into the ActionBar.

setDisplayHomeAsUpEnabled

abstract fun setDisplayHomeAsUpEnabled(showHomeAsUp: Boolean): Unit

Set whether home should be displayed as an "up" affordance. Set this to true if selecting "home" returns up by a single level in your UI rather than back to the top level or front page.

To set several display options at once, see the setDisplayOptions methods.

Parameters
showHomeAsUp Boolean: true to show the user that selecting home will return one level up rather than to the top level of the app.

setDisplayOptions

abstract fun setDisplayOptions(options: Int): Unit

Set display options. This changes all display option bits at once. To change a limited subset of display options, see setDisplayOptions(int, int).

Parameters
options Int: A combination of the bits defined by the DISPLAY_ constants defined in ActionBar.

setDisplayOptions

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

Set selected display options. Only the options specified by mask will be changed. To change all display option bits at once, see setDisplayOptions(int).

Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the DISPLAY_SHOW_HOME option. setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO) will enable DISPLAY_SHOW_HOME and disable DISPLAY_USE_LOGO.

Parameters
options Int: A combination of the bits defined by the DISPLAY_ constants defined in ActionBar.
mask Int: A bit mask declaring which display options should be changed.

setDisplayShowCustomEnabled

abstract fun setDisplayShowCustomEnabled(showCustom: Boolean): Unit

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

To set several display options at once, see the setDisplayOptions methods.

Parameters
showCustom Boolean: true if the currently set custom view should be displayed, false otherwise.

setDisplayShowHomeEnabled

abstract fun setDisplayShowHomeEnabled(showHome: Boolean): Unit

Set whether to include the application home affordance in the action bar. Home is presented as either an activity icon or logo.

To set several display options at once, see the setDisplayOptions methods.

Parameters
showHome Boolean: true to show home, false otherwise.

setDisplayShowTitleEnabled

abstract fun setDisplayShowTitleEnabled(showTitle: Boolean): Unit

Set whether an activity title/subtitle should be displayed.

To set several display options at once, see the setDisplayOptions methods.

Parameters
showTitle Boolean: true to display a title/subtitle if present.

setDisplayUseLogoEnabled

abstract fun setDisplayUseLogoEnabled(: Boolean): Unit

Set whether to display the activity logo rather than the activity icon. A logo is often a wider, more detailed image.

To set several display options at once, see the setDisplayOptions methods.

Parameters
useLogo Boolean: true to use the activity logo, false to use the activity icon.

setElevation

open fun setElevation(elevation: Float): Unit

Set the Z-axis elevation of the action bar in pixels.

The action bar's elevation is the distance it is placed from its parent surface. Higher values are closer to the user.

Parameters
elevation Float: Elevation value in pixels

setHideOffset

open fun setHideOffset(offset: Int): Unit

Set the current hide offset of the action bar.

The action bar's current hide offset is the distance that the action bar is currently scrolled offscreen in pixels. The valid range is 0 (fully visible) to the action bar's current measured height (fully invisible).

Parameters
offset Int: The action bar's offset toward its fully hidden state in pixels.

setHideOnContentScrollEnabled

open fun setHideOnContentScrollEnabled(hideOnContentScroll: Boolean): Unit

Enable hiding the action bar on content scroll.

If enabled, the action bar will scroll out of sight along with a nested scrolling child view's content. The action bar must be in overlay mode to enable hiding on content scroll.

When partially scrolled off screen the action bar is considered hidden. A call to show will cause it to return to full view.

Parameters
hideOnContentScroll Boolean: true to enable hiding on content scroll.

setHomeActionContentDescription

open fun setHomeActionContentDescription(@Nullable description: CharSequence?): Unit

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

This description is commonly used for accessibility/screen readers when the Home action is enabled. (See setDisplayHomeAsUpEnabled(boolean).) Examples of this are, "Navigate Home" or "Navigate Up" depending on the DISPLAY_HOME_AS_UP display option. If you have changed the home-as-up indicator using setHomeAsUpIndicator(int) to indicate more specific functionality such as a sliding drawer, you should also set this to accurately describe the action.

Setting this to null will use the system default description.

Parameters
description CharSequence?: New description for the Home action when enabled

setHomeActionContentDescription

open fun setHomeActionContentDescription(@StringRes resId: Int): Unit

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

This description is commonly used for accessibility/screen readers when the Home action is enabled. (See setDisplayHomeAsUpEnabled(boolean).) Examples of this are, "Navigate Home" or "Navigate Up" depending on the DISPLAY_HOME_AS_UP display option. If you have changed the home-as-up indicator using setHomeAsUpIndicator(int) to indicate more specific functionality such as a sliding drawer, you should also set this to accurately describe the action.

Setting this to 0 will use the system default description.

Parameters
resId Int: Resource ID of a string to use as the new description for the Home action when enabled

setHomeAsUpIndicator

open fun setHomeAsUpIndicator(@Nullable indicator: Drawable?): Unit

Set an alternate drawable to display next to the icon/logo/title when DISPLAY_HOME_AS_UP is enabled. This can be useful if you are using this mode to display an alternate selection for up navigation, such as a sliding drawer.

If you pass null to this method, the default drawable from the theme will be used.

If you implement alternate or intermediate behavior around Up, you should also call setHomeActionContentDescription() to provide a correct description of the action for accessibility support.

Parameters
indicator Drawable?: A drawable to use for the up indicator, or null to use the theme's default

setHomeAsUpIndicator

open fun setHomeAsUpIndicator(@DrawableRes resId: Int): Unit

Set an alternate drawable to display next to the icon/logo/title when DISPLAY_HOME_AS_UP is enabled. This can be useful if you are using this mode to display an alternate selection for up navigation, such as a sliding drawer.

If you pass 0 to this method, the default drawable from the theme will be used.

If you implement alternate or intermediate behavior around Up, you should also call setHomeActionContentDescription() to provide a correct description of the action for accessibility support.

Parameters
resId Int: Resource ID of a drawable to use for the up indicator, or null to use the theme's default

setHomeButtonEnabled

open fun setHomeButtonEnabled(enabled: Boolean): Unit

Enable or disable the "home" button in the corner of the action bar. (Note that this is the application home/up affordance on the action bar, not the system wide home button.)

This defaults to true for packages targeting < API 14. For packages targeting API 14 or greater, the application should call this method to enable interaction with the home/up affordance.

Setting the DISPLAY_HOME_AS_UP display option will automatically enable the home button.

Parameters
enabled Boolean: true to enable the home button, false to disable the home button.

setIcon

abstract fun setIcon(@DrawableRes resId: Int): Unit

Set the icon to display in the 'home' section of the action bar. The action bar will use an icon specified by its style or the activity icon by default. Whether the home section shows an icon or logo is controlled by the display option DISPLAY_USE_LOGO.

Parameters
resId Int: Resource ID of a drawable to show as an icon.

setIcon

abstract fun setIcon(icon: Drawable!): Unit

Set the icon to display in the 'home' section of the action bar. The action bar will use an icon specified by its style or the activity icon by default. Whether the home section shows an icon or logo is controlled by the display option DISPLAY_USE_LOGO.

Parameters
icon Drawable!: Drawable to show as an icon.

setListNavigationCallbacks

abstract fun setListNavigationCallbacks(adapter: SpinnerAdapter!, callback: ActionBar.OnNavigationListener!): Unit

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

Set the adapter and navigation callback for list navigation mode. The supplied adapter will provide views for the expanded list as well as the currently selected item. (These may be displayed differently.) The supplied OnNavigationListener will alert the application when the user changes the current list selection.

Parameters
adapter SpinnerAdapter!: An adapter that will provide views both to display the current navigation selection and populate views within the dropdown navigation menu.
callback SpinnerAdapter!: An OnNavigationListener that will receive events when the user selects a navigation item.

setLogo

abstract fun setLogo(@DrawableRes resId: Int): Unit

Set the logo to display in the 'home' section of the action bar. The action bar will use a logo specified by its style or the activity logo by default. Whether the home section shows an icon or logo is controlled by the display option DISPLAY_USE_LOGO.

Parameters
resId Int: Resource ID of a drawable to show as a logo.

setLogo

abstract fun setLogo(: Drawable!): Unit

Set the logo to display in the 'home' section of the action bar. The action bar will use a logo specified by its style or the activity logo by default. Whether the home section shows an icon or logo is controlled by the display option DISPLAY_USE_LOGO.

Parameters
logo Drawable!: Drawable to show as a logo.

setNavigationMode

abstract fun setNavigationMode(mode: Int): Unit

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

Set the current navigation mode.

Parameters
mode Int: The new mode to set.

setSelectedNavigationItem

abstract fun setSelectedNavigationItem(position: Int): Unit

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

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

Parameters
position Int: Position of the item to select.

setSplitBackgroundDrawable

open fun setSplitBackgroundDrawable(d: Drawable!): Unit

Set the ActionBar's split background. This will appear in the split action bar containing menu-provided action buttons on some devices and configurations.

You can enable split action bar with android.R.attr#uiOptions

Parameters
d Drawable!: Background drawable for the split bar

setStackedBackgroundDrawable

open fun setStackedBackgroundDrawable(d: Drawable!): Unit

Set the ActionBar's stacked background. This will appear in the second row/stacked bar on some devices and configurations.

Parameters
d Drawable!: Background drawable for the stacked row

setSubtitle

abstract fun setSubtitle(subtitle: CharSequence!): Unit

Set the action bar's subtitle. This will only be displayed if DISPLAY_SHOW_TITLE is set. Set to null to disable the subtitle entirely.

Parameters
subtitle CharSequence!: Subtitle to set

setSubtitle

abstract fun setSubtitle(resId: Int): Unit

Set the action bar's subtitle. This will only be displayed if DISPLAY_SHOW_TITLE is set.

Parameters
resId Int: Resource ID of subtitle string to set

setTitle

abstract fun setTitle(title: CharSequence!): Unit

Set the action bar's title. This will only be displayed if DISPLAY_SHOW_TITLE is set.

Parameters
title CharSequence!: Title to set

setTitle

abstract fun setTitle(@StringRes resId: Int): Unit

Set the action bar's title. This will only be displayed if DISPLAY_SHOW_TITLE is set.

Parameters
resId Int: Resource ID of title string to set

show

abstract fun show(): Unit

Show the ActionBar if it is not currently showing. If the window hosting the ActionBar does not have the feature Window#FEATURE_ACTION_BAR_OVERLAY it will resize application content to fit the new space available.

If you are hiding the ActionBar through View.SYSTEM_UI_FLAG_FULLSCREEN, you should not call this function directly.