public abstract class ActionBar extends Object
Beginning with Android 3.0 (API level 11), the action bar appears at the top of an
activity's window when the activity uses the system's Holo
theme (or one of its descendant themes), which is the default.
You may otherwise add the action bar by calling requestFeature(FEATURE_ACTION_BAR)
or by declaring it in a
custom theme with the windowActionBar
property.
Beginning with Android L (API level 21), 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.
By adjusting the window features requested by the theme and the layouts used for
an Activity's content view, an app can use the standard system action bar on older platform
releases and the newer inline toolbars on newer platform releases. The ActionBar
object obtained from the Activity can be used to control either configuration transparently.
When using the Holo themes the action bar shows the application icon on the left, followed by the activity title. 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.
When using the Material themes (default in API 21 or newer) 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 getActionBar()
.
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
.
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.
Modifier and Type | Class and Description |
---|---|
static interface |
ActionBar.DisplayOptions |
static class |
ActionBar.LayoutParams
Per-child layout information associated with action bar custom views.
|
static interface |
ActionBar.NavigationMode |
static interface |
ActionBar.OnMenuVisibilityListener
Listener for receiving events when action bar menus are shown or hidden.
|
static interface |
ActionBar.OnNavigationListener
Deprecated.
Action bar navigation modes are deprecated and not supported by inline
toolbar action bars. Consider using other
common
navigation patterns instead.
|
static class |
ActionBar.Tab
Deprecated.
Action bar navigation modes are deprecated and not supported by inline
toolbar action bars. Consider using other
common
navigation patterns instead.
|
static interface |
ActionBar.TabListener
Deprecated.
Action bar navigation modes are deprecated and not supported by inline
toolbar action bars. Consider using other
common
navigation patterns instead.
|
Modifier and Type | Field and Description |
---|---|
static int |
DISPLAY_HOME_AS_UP
Display the 'home' element such that it appears as an 'up' affordance.
|
static int |
DISPLAY_SHOW_CUSTOM
Show the custom view if one has been set.
|
static int |
DISPLAY_SHOW_HOME
Show 'home' elements in this action bar, leaving more space for other
navigation elements.
|
static int |
DISPLAY_SHOW_TITLE
Show the activity title and subtitle, if present.
|
static int |
DISPLAY_TITLE_MULTIPLE_LINES
Allow the title to wrap onto multiple lines if space is available
|
static int |
DISPLAY_USE_LOGO
Use logo instead of icon if available.
|
static int |
NAVIGATION_MODE_LIST
Deprecated.
Action bar navigation modes are deprecated and not supported by inline
toolbar action bars. Consider using other
common
navigation patterns instead.
|
static int |
NAVIGATION_MODE_STANDARD
Deprecated.
Action bar navigation modes are deprecated and not supported by inline
toolbar action bars. Consider using other
common
navigation patterns instead.
|
static int |
NAVIGATION_MODE_TABS
Deprecated.
Action bar navigation modes are deprecated and not supported by inline
toolbar action bars. Consider using other
common
navigation patterns instead.
|
Constructor and Description |
---|
ActionBar() |
Modifier and Type | Method and Description |
---|---|
abstract void |
addOnMenuVisibilityListener(ActionBar.OnMenuVisibilityListener listener)
Add a listener that will respond to menu visibility change events.
|
abstract void |
addTab(ActionBar.Tab tab)
Deprecated.
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)
Deprecated.
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)
Deprecated.
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)
Deprecated.
Action bar navigation modes are deprecated and not supported by inline
toolbar action bars. Consider using other
common
navigation patterns instead.
|
boolean |
collapseActionView() |
void |
dispatchMenuVisibilityChanged(boolean visible) |
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()
Deprecated.
Action bar navigation modes are deprecated and not supported by inline
toolbar action bars. Consider using other
common
navigation patterns instead.
|
abstract int |
getNavigationMode()
Deprecated.
Action bar navigation modes are deprecated and not supported by inline
toolbar action bars. Consider using other
common
navigation patterns instead.
|
abstract int |
getSelectedNavigationIndex()
Deprecated.
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()
Deprecated.
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)
Deprecated.
Action bar navigation modes are deprecated and not supported by inline
toolbar action bars. Consider using other
common
navigation patterns instead.
|
abstract int |
getTabCount()
Deprecated.
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
Context with an appropriate theme for creating views that
will appear in the action bar. |
abstract CharSequence |
getTitle()
Returns the current ActionBar title in standard mode.
|
abstract void |
hide()
Hide the ActionBar if it is currently showing.
|
boolean |
invalidateOptionsMenu() |
boolean |
isHideOnContentScrollEnabled()
Return whether the action bar is configured to scroll out of sight along with
a
nested scrolling child . |
abstract boolean |
isShowing() |
boolean |
isTitleTruncated()
Returns true if the Title field has been truncated during layout for lack
of available space.
|
abstract ActionBar.Tab |
newTab()
Deprecated.
Action bar navigation modes are deprecated and not supported by inline
toolbar action bars. Consider using other
common
navigation patterns instead.
|
void |
onConfigurationChanged(Configuration config) |
void |
onDestroy() |
boolean |
onKeyShortcut(int keyCode,
KeyEvent event) |
boolean |
onMenuKeyEvent(KeyEvent event) |
boolean |
openOptionsMenu() |
abstract void |
removeAllTabs()
Deprecated.
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)
Deprecated.
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)
Deprecated.
Action bar navigation modes are deprecated and not supported by inline
toolbar action bars. Consider using other
common
navigation patterns instead.
|
boolean |
requestFocus()
Attempts to move focus to the ActionBar if it does not already contain the focus.
|
protected boolean |
requestFocus(ViewGroup viewGroup)
Common implementation for requestFocus that takes in the Toolbar and moves focus
to the contents.
|
abstract void |
selectTab(ActionBar.Tab tab)
Deprecated.
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(int resId)
Set the action bar into custom navigation mode, supplying a view
for custom navigation.
|
abstract void |
setCustomView(View view)
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.
|
void |
setDefaultDisplayHomeAsUpEnabled(boolean enabled) |
abstract void |
setDisplayHomeAsUpEnabled(boolean showHomeAsUp)
Set whether home should be displayed as an "up" affordance.
|
abstract void |
setDisplayOptions(int options)
Set display options.
|
abstract void |
setDisplayOptions(int options,
int mask)
Set selected 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(Drawable indicator)
Set an alternate drawable to display next to the icon/logo/title
when
DISPLAY_HOME_AS_UP is enabled. |
void |
setHomeAsUpIndicator(int resId)
Set an alternate drawable to display next to the icon/logo/title
when
DISPLAY_HOME_AS_UP is enabled. |
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)
Deprecated.
Action bar navigation modes are deprecated and not supported by inline
toolbar action bars. Consider using other
common
navigation patterns instead.
|
abstract void |
setLogo(Drawable logo)
Set the logo to display in the 'home' section of the action bar.
|
abstract void |
setLogo(int resId)
Set the logo to display in the 'home' section of the action bar.
|
abstract void |
setNavigationMode(int mode)
Deprecated.
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)
Deprecated.
Action bar navigation modes are deprecated and not supported by inline
toolbar action bars. Consider using other
common
navigation patterns instead.
|
void |
setShowHideAnimationEnabled(boolean enabled) |
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.
|
void |
setWindowTitle(CharSequence title) |
abstract void |
show()
Show the ActionBar if it is not currently showing.
|
ActionMode |
startActionMode(ActionMode.Callback callback) |
public static final int NAVIGATION_MODE_STANDARD
public static final int NAVIGATION_MODE_LIST
public static final int NAVIGATION_MODE_TABS
public static final int DISPLAY_USE_LOGO
public static final int DISPLAY_SHOW_HOME
public static final int DISPLAY_HOME_AS_UP
Setting this option will implicitly enable interaction with the home/up
button. See setHomeButtonEnabled(boolean)
.
public static final int DISPLAY_SHOW_TITLE
public static final int DISPLAY_SHOW_CUSTOM
public static final int DISPLAY_TITLE_MULTIPLE_LINES
public abstract void setCustomView(View view)
view
- Custom navigation view to place in the ActionBar.public abstract void setCustomView(View view, ActionBar.LayoutParams layoutParams)
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.
view
- Custom navigation view to place in the ActionBar.layoutParams
- How this custom view should layout in the bar.setDisplayOptions(int, int)
public abstract void setCustomView(@LayoutRes int resId)
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.
resId
- Resource ID of a layout to inflate into the ActionBar.setDisplayOptions(int, int)
public abstract void setIcon(@DrawableRes int resId)
DISPLAY_USE_LOGO
.resId
- Resource ID of a drawable to show as an icon.setDisplayUseLogoEnabled(boolean)
,
setDisplayShowHomeEnabled(boolean)
public abstract void setIcon(Drawable icon)
DISPLAY_USE_LOGO
.icon
- Drawable to show as an icon.setDisplayUseLogoEnabled(boolean)
,
setDisplayShowHomeEnabled(boolean)
public abstract void setLogo(@DrawableRes int resId)
DISPLAY_USE_LOGO
.resId
- Resource ID of a drawable to show as a logo.setDisplayUseLogoEnabled(boolean)
,
setDisplayShowHomeEnabled(boolean)
public abstract void setLogo(Drawable logo)
DISPLAY_USE_LOGO
.logo
- Drawable to show as a logo.setDisplayUseLogoEnabled(boolean)
,
setDisplayShowHomeEnabled(boolean)
public abstract void setListNavigationCallbacks(SpinnerAdapter adapter, ActionBar.OnNavigationListener callback)
adapter
- An adapter that will provide views both to display
the current navigation selection and populate views
within the dropdown navigation menu.callback
- An OnNavigationListener that will receive events when the user
selects a navigation item.public abstract void setSelectedNavigationItem(int position)
position
- Position of the item to select.public abstract int getSelectedNavigationIndex()
public abstract int getNavigationItemCount()
public abstract void setTitle(CharSequence title)
DISPLAY_SHOW_TITLE
is set.title
- Title to setsetTitle(int)
,
setDisplayOptions(int, int)
public abstract void setTitle(@StringRes int resId)
DISPLAY_SHOW_TITLE
is set.resId
- Resource ID of title string to setsetTitle(CharSequence)
,
setDisplayOptions(int, int)
public abstract void setSubtitle(CharSequence subtitle)
DISPLAY_SHOW_TITLE
is set. Set to null to disable the
subtitle entirely.subtitle
- Subtitle to setsetSubtitle(int)
,
setDisplayOptions(int, int)
public abstract void setSubtitle(@StringRes int resId)
DISPLAY_SHOW_TITLE
is set.resId
- Resource ID of subtitle string to setsetSubtitle(CharSequence)
,
setDisplayOptions(int, int)
public abstract void setDisplayOptions(int options)
setDisplayOptions(int, int)
.options
- A combination of the bits defined by the DISPLAY_ constants
defined in ActionBar.public abstract void setDisplayOptions(int options, int mask)
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
.
options
- A combination of the bits defined by the DISPLAY_ constants
defined in ActionBar.mask
- A bit mask declaring which display options should be changed.public abstract void setDisplayUseLogoEnabled(boolean useLogo)
To set several display options at once, see the setDisplayOptions methods.
useLogo
- true to use the activity logo, false to use the activity icon.setDisplayOptions(int)
,
setDisplayOptions(int, int)
public abstract void setDisplayShowHomeEnabled(boolean showHome)
To set several display options at once, see the setDisplayOptions methods.
showHome
- true to show home, false otherwise.setDisplayOptions(int)
,
setDisplayOptions(int, int)
public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp)
To set several display options at once, see the setDisplayOptions methods.
showHomeAsUp
- true to show the user that selecting home will return one
level up rather than to the top level of the app.setDisplayOptions(int)
,
setDisplayOptions(int, int)
public abstract void setDisplayShowTitleEnabled(boolean showTitle)
To set several display options at once, see the setDisplayOptions methods.
showTitle
- true to display a title/subtitle if present.setDisplayOptions(int)
,
setDisplayOptions(int, int)
public abstract void setDisplayShowCustomEnabled(boolean showCustom)
To set several display options at once, see the setDisplayOptions methods.
showCustom
- true if the currently set custom view should be displayed, false otherwise.setDisplayOptions(int)
,
setDisplayOptions(int, int)
public abstract void setBackgroundDrawable(Drawable d)
d
- Background drawablesetStackedBackgroundDrawable(Drawable)
,
setSplitBackgroundDrawable(Drawable)
public void setStackedBackgroundDrawable(Drawable d)
d
- Background drawable for the stacked rowpublic void setSplitBackgroundDrawable(Drawable d)
You can enable split action bar with android.R.attr#uiOptions
d
- Background drawable for the split barpublic abstract View getCustomView()
public abstract CharSequence getTitle()
getNavigationMode()
would not return
NAVIGATION_MODE_STANDARD
.public abstract CharSequence getSubtitle()
getNavigationMode()
would not return
NAVIGATION_MODE_STANDARD
.public abstract int getNavigationMode()
public abstract void setNavigationMode(int mode)
mode
- The new mode to set.NAVIGATION_MODE_STANDARD
,
NAVIGATION_MODE_LIST
,
NAVIGATION_MODE_TABS
public abstract int getDisplayOptions()
public abstract ActionBar.Tab newTab()
ActionBar.Tab
.
This tab will not be included in the action bar until it is added.
Very often tabs will be used to switch between Fragment
objects. Here is a typical implementation of such tabs:
addTab(Tab)
public abstract void addTab(ActionBar.Tab tab)
tab
- Tab to addpublic abstract void addTab(ActionBar.Tab tab, boolean setSelected)
tab
- Tab to addsetSelected
- True if the added tab should become the selected tab.public abstract void addTab(ActionBar.Tab tab, int position)
position
. If this is the first tab to be added it will become
the selected tab.tab
- The tab to addposition
- The new position of the tabpublic abstract void addTab(ActionBar.Tab tab, int position, boolean setSelected)
position
.tab
- The tab to addposition
- The new position of the tabsetSelected
- True if the added tab should become the selected tab.public abstract void removeTab(ActionBar.Tab tab)
tab
- The tab to removepublic abstract void removeTabAt(int position)
position
- Position of the tab to removepublic abstract void removeAllTabs()
public abstract void selectTab(ActionBar.Tab tab)
Note: If you want to select by index, use setSelectedNavigationItem(int)
.
tab
- Tab to selectpublic abstract ActionBar.Tab getSelectedTab()
public abstract ActionBar.Tab getTabAt(int index)
index
- Index value in the range 0-getpublic abstract int getTabCount()
public abstract int getHeight()
public abstract void show()
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.
public abstract void hide()
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.
public abstract boolean isShowing()
true
if the ActionBar is showing, false
otherwise.public abstract void addOnMenuVisibilityListener(ActionBar.OnMenuVisibilityListener listener)
listener
- The new listener to addpublic abstract void removeOnMenuVisibilityListener(ActionBar.OnMenuVisibilityListener listener)
listener
- A listener to remove that was previously addedpublic void setHomeButtonEnabled(boolean enabled)
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.
enabled
- true to enable the home button, false to disable the home button.public Context getThemedContext()
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.public boolean isTitleTruncated()
public void setHomeAsUpIndicator(Drawable indicator)
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.
indicator
- A drawable to use for the up indicator, or null to use the theme's defaultsetDisplayOptions(int, int)
,
setDisplayHomeAsUpEnabled(boolean)
,
setHomeActionContentDescription(int)
public void setHomeAsUpIndicator(@DrawableRes int resId)
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.
resId
- Resource ID of a drawable to use for the up indicator, or null
to use the theme's defaultsetDisplayOptions(int, int)
,
setDisplayHomeAsUpEnabled(boolean)
,
setHomeActionContentDescription(int)
public void setHomeActionContentDescription(CharSequence description)
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.
description
- New description for the Home action when enabledsetHomeAsUpIndicator(int)
,
setHomeAsUpIndicator(android.graphics.drawable.Drawable)
public void setHomeActionContentDescription(@StringRes int resId)
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.
resId
- Resource ID of a string to use as the new description
for the Home action when enabledsetHomeAsUpIndicator(int)
,
setHomeAsUpIndicator(android.graphics.drawable.Drawable)
public void setHideOnContentScrollEnabled(boolean hideOnContentScroll)
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.
hideOnContentScroll
- true to enable hiding on content scroll.public boolean isHideOnContentScrollEnabled()
nested scrolling child
.setHideOnContentScrollEnabled(boolean)
public int getHideOffset()
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).
public void setHideOffset(int offset)
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).
offset
- The action bar's offset toward its fully hidden state in pixels.public void setElevation(float elevation)
The action bar's elevation is the distance it is placed from its parent surface. Higher values are closer to the user.
elevation
- Elevation value in pixelspublic float getElevation()
The action bar's elevation is the distance it is placed from its parent surface. Higher values are closer to the user.
public void setDefaultDisplayHomeAsUpEnabled(boolean enabled)
public void setShowHideAnimationEnabled(boolean enabled)
public void onConfigurationChanged(Configuration config)
public void dispatchMenuVisibilityChanged(boolean visible)
public ActionMode startActionMode(ActionMode.Callback callback)
public boolean openOptionsMenu()
public boolean invalidateOptionsMenu()
public boolean onMenuKeyEvent(KeyEvent event)
public boolean onKeyShortcut(int keyCode, KeyEvent event)
public boolean collapseActionView()
public void setWindowTitle(CharSequence title)
public boolean requestFocus()
true
if focus changes or false
if focus doesn't change.public void onDestroy()
protected boolean requestFocus(ViewGroup viewGroup)
viewGroup
- The toolbar ViewGrouptrue
if focus changes or false
if focus doesn't change.