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 |