ActionBar

abstract class ActionBar(source)

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 requestFeature(FEATURE_SUPPORT_ACTION_BAR) 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 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.

Inheritors

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
Link copied to clipboard
Per-child layout information associated with action bar custom views.
Link copied to clipboard
Link copied to clipboard
Listener for receiving events when action bar menus are shown or hidden.
Link copied to clipboard
Listener interface for ActionBar navigation events.
Link copied to clipboard
abstract class Tab
A tab in the action bar.
Link copied to clipboard
interface TabListener
Callback interface invoked when a tab is focused, unfocused, added, or removed.

Properties

Link copied to clipboard
Display the 'home' element such that it appears as an 'up' affordance.
Link copied to clipboard
Show the custom view if one has been set.
Link copied to clipboard
Show 'home' elements in this action bar, leaving more space for other navigation elements.
Link copied to clipboard
Show the activity title and subtitle, if present.
Link copied to clipboard
Use logo instead of icon if available.
Link copied to clipboard
List navigation mode.
Link copied to clipboard
Standard navigation mode.
Link copied to clipboard
Tab navigation mode.

Functions

Link copied to clipboard
Add a listener that will respond to menu visibility change events.
Link copied to clipboard
abstract fun addTab(tab: ActionBar.Tab)
abstract fun addTab(tab: ActionBar.Tab, setSelected: Boolean)
abstract fun addTab(tab: ActionBar.Tab, position: Int)
abstract fun addTab(tab: ActionBar.Tab, position: Int, setSelected: Boolean)
Add a tab for use in tabbed navigation mode.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract fun getCustomView(): View
Link copied to clipboard
abstract fun getDisplayOptions(): Int
Link copied to clipboard
open fun getElevation(): Float
Get the Z-axis elevation of the action bar in pixels.
Link copied to clipboard
abstract fun getHeight(): Int
Retrieve the current height of the ActionBar.
Link copied to clipboard
open fun getHideOffset(): Int
Return the current vertical offset of the action bar.
Link copied to clipboard
abstract fun getNavigationItemCount(): Int
Get the number of navigation items present in the current navigation mode.
Link copied to clipboard
abstract fun getNavigationMode(): Int
Returns the current navigation mode.
Link copied to clipboard
Get the position of the selected navigation item in list or tabbed navigation modes.
Link copied to clipboard
@Nullable
abstract fun getSelectedTab(): @Nullable ActionBar.Tab
Returns the currently selected tab if in tabbed navigation mode and there is at least one tab present.
Link copied to clipboard
@Nullable
abstract fun getSubtitle(): @Nullable CharSequence
Returns the current ActionBar subtitle in standard mode.
Link copied to clipboard
abstract fun getTabAt(index: Int): ActionBar.Tab
Returns the tab at the specified index.
Link copied to clipboard
abstract fun getTabCount(): Int
Returns the number of tabs currently registered with the action bar.
Link copied to clipboard
Returns a Context with an appropriate theme for creating views that will appear in the action bar.
Link copied to clipboard
@Nullable
abstract fun getTitle(): @Nullable CharSequence
Returns the current ActionBar title in standard mode.
Link copied to clipboard
abstract fun hide()
Hide the ActionBar if it is currently showing.
Link copied to clipboard
Return whether the action bar is configured to scroll out of sight along with a nested scrolling child.
Link copied to clipboard
abstract fun isShowing(): Boolean
Link copied to clipboard
Returns true if the Title field has been truncated during layout for lack of available space.
Link copied to clipboard
abstract fun newTab(): ActionBar.Tab
Create and return a new Tab.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract fun removeAllTabs()
Remove all tabs from the action bar and deselect the current tab.
Link copied to clipboard
Remove a menu visibility listener.
Link copied to clipboard
abstract fun removeTab(tab: ActionBar.Tab)
Remove a tab from the action bar.
Link copied to clipboard
abstract fun removeTabAt(position: Int)
Remove a tab from the action bar.
Link copied to clipboard
abstract fun selectTab(tab: ActionBar.Tab)
Select the specified tab.
Link copied to clipboard
abstract fun setBackgroundDrawable(@Nullable d: @Nullable Drawable)
Set the ActionBar's background.
Link copied to clipboard
abstract fun setCustomView(view: View)
abstract fun setCustomView(resId: Int)
abstract fun setCustomView(view: View, layoutParams: ActionBar.LayoutParams)
Set the action bar into custom navigation mode, supplying a view for custom navigation.
Link copied to clipboard
abstract fun setDisplayHomeAsUpEnabled(showHomeAsUp: Boolean)
Set whether home should be displayed as an "up" affordance.
Link copied to clipboard
abstract fun setDisplayOptions(options: Int)
Set display options.
abstract fun setDisplayOptions(options: Int, mask: Int)
Set selected display options.
Link copied to clipboard
abstract fun setDisplayShowCustomEnabled(showCustom: Boolean)
Set whether a custom view should be displayed, if set.
Link copied to clipboard
abstract fun setDisplayShowHomeEnabled(showHome: Boolean)
Set whether to include the application home affordance in the action bar.
Link copied to clipboard
abstract fun setDisplayShowTitleEnabled(showTitle: Boolean)
Set whether an activity title/subtitle should be displayed.
Link copied to clipboard
abstract fun setDisplayUseLogoEnabled(useLogo: Boolean)
Set whether to display the activity logo rather than the activity icon.
Link copied to clipboard
open fun setElevation(elevation: Float)
Set the Z-axis elevation of the action bar in pixels.
Link copied to clipboard
open fun setHideOffset(offset: Int)
Set the current hide offset of the action bar.
Link copied to clipboard
open fun setHideOnContentScrollEnabled(hideOnContentScroll: Boolean)
Enable hiding the action bar on content scroll.
Link copied to clipboard
open fun setHomeActionContentDescription(@Nullable description: @Nullable CharSequence)
Set an alternate description for the Home/Up action, when enabled.
Link copied to clipboard
open fun setHomeAsUpIndicator(@Nullable indicator: @Nullable Drawable)
Set an alternate drawable to display next to the icon/logo/title when DISPLAY_HOME_AS_UP is enabled.
Link copied to clipboard
open fun setHomeButtonEnabled(enabled: Boolean)
Enable or disable the "home" button in the corner of the action bar.
Link copied to clipboard
abstract fun setIcon(icon: Drawable)
abstract fun setIcon(@DrawableRes resId: Int)
Set the icon to display in the 'home' section of the action bar.
Link copied to clipboard
Set the adapter and navigation callback for list navigation mode.
Link copied to clipboard
abstract fun setLogo(logo: Drawable)
abstract fun setLogo(@DrawableRes resId: Int)
Set the logo to display in the 'home' section of the action bar.
Link copied to clipboard
abstract fun setNavigationMode(mode: Int)
Set the current navigation mode.
Link copied to clipboard
abstract fun setSelectedNavigationItem(position: Int)
Set the selected navigation item in list or tabbed navigation modes.
Link copied to clipboard
Set the ActionBar's split background.
Link copied to clipboard
Set the ActionBar's stacked background.
Link copied to clipboard
abstract fun setSubtitle(resId: Int)
abstract fun setSubtitle(subtitle: CharSequence)
Set the action bar's subtitle.
Link copied to clipboard
abstract fun setTitle(@StringRes resId: Int)
abstract fun setTitle(title: CharSequence)
Set the action bar's title.
Link copied to clipboard
Link copied to clipboard
abstract fun show()
Show the ActionBar if it is not currently showing.
Link copied to clipboard