belongs to Maven artifact com.android.support:appcompat-v7:28.0.0-alpha1
ActionBar
public
abstract
class
ActionBar
extends Object
java.lang.Object | |
↳ | android.support.v7.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 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
.
Developer Guides
For information about how to use the action bar, including how to add action items, navigation modes and more, read the Action Bar developer guide.
Summary
Nested classes | |
---|---|
class |
ActionBar.LayoutParams
Per-child layout information associated with action bar custom views. |
interface |
ActionBar.OnMenuVisibilityListener
Listener for receiving events when action bar menus are shown or hidden. |
interface |
ActionBar.OnNavigationListener
This interface was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
class |
ActionBar.Tab
This class was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
interface |
ActionBar.TabListener
This interface was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
Constants | |
---|---|
int |
DISPLAY_HOME_AS_UP
Display the 'home' element such that it appears as an 'up' affordance. |
int |
DISPLAY_SHOW_CUSTOM
Show the custom view if one has been set. |
int |
DISPLAY_SHOW_HOME
Show 'home' elements in this action bar, leaving more space for other navigation elements. |
int |
DISPLAY_SHOW_TITLE
Show the activity title and subtitle, if present. |
int |
DISPLAY_USE_LOGO
Use logo instead of icon if available. |
int |
NAVIGATION_MODE_LIST
This constant was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
int |
NAVIGATION_MODE_STANDARD
This constant was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
int |
NAVIGATION_MODE_TABS
This constant was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
Public constructors | |
---|---|
ActionBar()
|
Public methods | |
---|---|
abstract
void
|
addOnMenuVisibilityListener(ActionBar.OnMenuVisibilityListener listener)
Add a listener that will respond to menu visibility change events. |
abstract
void
|
addTab(ActionBar.Tab tab, int position)
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
abstract
void
|
addTab(ActionBar.Tab tab)
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
abstract
void
|
addTab(ActionBar.Tab tab, int position, boolean setSelected)
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
abstract
void
|
addTab(ActionBar.Tab tab, boolean setSelected)
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
abstract
View
|
getCustomView()
|
abstract
int
|
getDisplayOptions()
|
float
|
getElevation()
Get the Z-axis elevation of the action bar in pixels. |
abstract
int
|
getHeight()
Retrieve the current height of the ActionBar. |
int
|
getHideOffset()
Return the current vertical offset of the action bar. |
abstract
int
|
getNavigationItemCount()
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
abstract
int
|
getNavigationMode()
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
abstract
int
|
getSelectedNavigationIndex()
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
abstract
ActionBar.Tab
|
getSelectedTab()
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
abstract
CharSequence
|
getSubtitle()
Returns the current ActionBar subtitle in standard mode. |
abstract
ActionBar.Tab
|
getTabAt(int index)
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
abstract
int
|
getTabCount()
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
Context
|
getThemedContext()
Returns a |
abstract
CharSequence
|
getTitle()
Returns the current ActionBar title in standard mode. |
abstract
void
|
hide()
Hide the ActionBar if it is currently showing. |
boolean
|
isHideOnContentScrollEnabled()
Return whether the action bar is configured to scroll out of sight along with
a |
abstract
boolean
|
isShowing()
|
abstract
ActionBar.Tab
|
newTab()
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
abstract
void
|
removeAllTabs()
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
abstract
void
|
removeOnMenuVisibilityListener(ActionBar.OnMenuVisibilityListener listener)
Remove a menu visibility listener. |
abstract
void
|
removeTab(ActionBar.Tab tab)
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
abstract
void
|
removeTabAt(int position)
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
abstract
void
|
selectTab(ActionBar.Tab tab)
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
abstract
void
|
setBackgroundDrawable(Drawable d)
Set the ActionBar's background. |
abstract
void
|
setCustomView(View view)
Set the action bar into custom navigation mode, supplying a view for custom navigation. |
abstract
void
|
setCustomView(int resId)
Set the action bar into custom navigation mode, supplying a view for custom navigation. |
abstract
void
|
setCustomView(View view, ActionBar.LayoutParams layoutParams)
Set the action bar into custom navigation mode, supplying a view for custom navigation. |
abstract
void
|
setDisplayHomeAsUpEnabled(boolean showHomeAsUp)
Set whether home should be displayed as an "up" affordance. |
abstract
void
|
setDisplayOptions(int options, int mask)
Set selected display options. |
abstract
void
|
setDisplayOptions(int options)
Set display options. |
abstract
void
|
setDisplayShowCustomEnabled(boolean showCustom)
Set whether a custom view should be displayed, if set. |
abstract
void
|
setDisplayShowHomeEnabled(boolean showHome)
Set whether to include the application home affordance in the action bar. |
abstract
void
|
setDisplayShowTitleEnabled(boolean showTitle)
Set whether an activity title/subtitle should be displayed. |
abstract
void
|
setDisplayUseLogoEnabled(boolean useLogo)
Set whether to display the activity logo rather than the activity icon. |
void
|
setElevation(float elevation)
Set the Z-axis elevation of the action bar in pixels. |
void
|
setHideOffset(int offset)
Set the current hide offset of the action bar. |
void
|
setHideOnContentScrollEnabled(boolean hideOnContentScroll)
Enable hiding the action bar on content scroll. |
void
|
setHomeActionContentDescription(CharSequence description)
Set an alternate description for the Home/Up action, when enabled. |
void
|
setHomeActionContentDescription(int resId)
Set an alternate description for the Home/Up action, when enabled. |
void
|
setHomeAsUpIndicator(int resId)
Set an alternate drawable to display next to the icon/logo/title
when |
void
|
setHomeAsUpIndicator(Drawable indicator)
Set an alternate drawable to display next to the icon/logo/title
when |
void
|
setHomeButtonEnabled(boolean enabled)
Enable or disable the "home" button in the corner of the action bar. |
abstract
void
|
setIcon(Drawable icon)
Set the icon to display in the 'home' section of the action bar. |
abstract
void
|
setIcon(int resId)
Set the icon to display in the 'home' section of the action bar. |
abstract
void
|
setListNavigationCallbacks(SpinnerAdapter adapter, ActionBar.OnNavigationListener callback)
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
abstract
void
|
setLogo(int resId)
Set the logo to display in the 'home' section of the action bar. |
abstract
void
|
setLogo(Drawable logo)
Set the logo to display in the 'home' section of the action bar. |
abstract
void
|
setNavigationMode(int mode)
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
abstract
void
|
setSelectedNavigationItem(int position)
This method was deprecated in API level 24.1.0. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. |
void
|
setSplitBackgroundDrawable(Drawable d)
Set the ActionBar's split background. |
void
|
setStackedBackgroundDrawable(Drawable d)
Set the ActionBar's stacked background. |
abstract
void
|
setSubtitle(CharSequence subtitle)
Set the action bar's subtitle. |
abstract
void
|
setSubtitle(int resId)
Set the action bar's subtitle. |
abstract
void
|
setTitle(CharSequence title)
Set the action bar's title. |
abstract
void
|
setTitle(int resId)
Set the action bar's title. |
abstract
void
|
show()
Show the ActionBar if it is not currently showing. |
Inherited methods | |
---|---|
![]()
java.lang.Object
|
Constants
DISPLAY_HOME_AS_UP
int DISPLAY_HOME_AS_UP
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)
.
Constant Value: 4 (0x00000004)
DISPLAY_SHOW_CUSTOM
int DISPLAY_SHOW_CUSTOM
Show the custom view if one has been set.
Constant Value: 16 (0x00000010)
DISPLAY_SHOW_HOME
int DISPLAY_SHOW_HOME
Show 'home' elements in this action bar, leaving more space for other navigation elements. This includes logo and icon.
Constant Value: 2 (0x00000002)
DISPLAY_SHOW_TITLE
int DISPLAY_SHOW_TITLE
Show the activity title and subtitle, if present.
See also:
Constant Value: 8 (0x00000008)
DISPLAY_USE_LOGO
int DISPLAY_USE_LOGO
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.
Constant Value: 1 (0x00000001)
NAVIGATION_MODE_LIST
int NAVIGATION_MODE_LIST
This constant was deprecated
in API level 24.1.0.
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.
Constant Value: 1 (0x00000001)
NAVIGATION_MODE_STANDARD
int NAVIGATION_MODE_STANDARD
This constant was deprecated
in API level 24.1.0.
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.
Constant Value: 0 (0x00000000)
NAVIGATION_MODE_TABS
int NAVIGATION_MODE_TABS
This constant was deprecated
in API level 24.1.0.
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.
Constant Value: 2 (0x00000002)
Public constructors
Public methods
addOnMenuVisibilityListener
void addOnMenuVisibilityListener (ActionBar.OnMenuVisibilityListener listener)
Add a listener that will respond to menu visibility change events.
Parameters | |
---|---|
listener |
ActionBar.OnMenuVisibilityListener : The new listener to add
|
addTab
void addTab (ActionBar.Tab tab, int position)
This method was deprecated
in API level 24.1.0.
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 |
int : The new position of the tab |
addTab
void addTab (ActionBar.Tab tab)
This method was deprecated
in API level 24.1.0.
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
void addTab (ActionBar.Tab tab, int position, boolean setSelected)
This method was deprecated in A