今天学习用到了actionbar,就试着去翻译了下官方文档来学习,英语水平有限

ActionBar

extends Object

java.lang.Object

android.app.ActionBar

Class Overview

A primary toolbar within the activity that may display the activity title, application-level navigation affordances, and other interactive items.

在activity中的一个主要的工具栏,它可以展示这个activity的标题,应用程序级的导航功能和其他的交互性元素。

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.

ActionBar在android 3.0被引入,在activity使用系统的Holo主题(或者集成该主题的后代主题)时,操作栏出现在activity窗口的顶部,这是默认的配置。否则你可以通过调用requestFeature(FEATURE_ACTION_BAR) 或者在一个自定义主题中用windowActionBar属性去增加操作栏(action bar)。

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.

从android L版本(API level 21)开始。应用程序布局中的操作栏可以用任意的Toolbar widget (工具栏小部件)去描述。应用程序告诉acitity工具栏是该作为这个activity的操作栏进行处理。拥有actionbar特性的activity将使用一个NoActionBar 主题提供支持。设置windowActionBar属性为false值或者不请求这个窗口特性。

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.

activity的文本视图增加这个窗口特性可通过主题和布局文件去调整,在老的平台发布应用程序时,应用程序可以使用标准的系统操作栏,在新的应用平台发布应用程序,应用程序可以使用最新的内联工具栏。ActionBar 对象从activity 中获得,该对象可以被使用去控制或者配置一些特性。

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.

当使用这Holo主题时,操作栏在左边展示应用程序的图标,接下来是activity 的标题。如果你的activity有一个可选的菜单,你可以直接从操作栏选择一个菜单项作为操作项直接进入。

你也可以修改操作栏的各种特性甚至完全删除它。

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.

当导航按钮(原名“home”)使用Material 主题(在api21或者以上被定义)时,将占据先前应用程序的图标的空间位置。应用程序希望在操作栏和其他应用程序的网格或者他们标准的标题文本中使用有logo的地方去突出的展示一个品牌效果,是该使用自己定义的颜色行为在操作栏中。

From your activity, you can retrieve an instance of ActionBar by calling getActionBar().

在activity中,你可以通过吊桶getActionBar()方法获得一个actionBar的实例对象。

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 forActionBar.

在某些情况下,使用一个ActionMode可以使操作栏可以被其它能共使用上下文的操作栏覆盖。例如,当用户在不得activity中选择一个或者更多的项,你可以开启一个提供选择指定项的操作模型作为一个用户界面元素,该元素零时取代操作栏。即使这UI可能占据一些内存空间,但是这个ActionMode API 是独特的,独立于其他的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.

有关如何去使用操作栏的更多信息,包括如何去添加一个操作项,导航模型或者更多其他的,请阅读Action bar 开发者向导

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 21. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead.

该接口在AIP 21被弃用,操作栏导航面板被启用,不被内联的工具栏 操作栏支持。考虑使用其他的公共导航模式代替

class
ActionBar.Tab
This class was deprecated in API level 21. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patternsinstead.

interface
ActionBar.TabListener
This interface was deprecated in API level 21. 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.

展示一个‘home‘元素以便提供一个’up‘的功能。

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.

在操作栏显示’home‘元素,为其他导航元素留下更多的空间

int
DISPLAY_SHOW_TITLE
Show the activity title and subtitle, if present.

如果acivity的标题和子标题存在,则展示出来。

int
DISPLAY_USE_LOGO
Use logo instead of icon if available.

如果可用使用logo去替换图标

int
NAVIGATION_MODE_LIST
This constant was deprecated in API level 21. 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 21. 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 21. 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, boolean setSelected)

This method was deprecated in API level 21. 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)

This method was deprecated in API level 21. 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 21. 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 21. 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.

以像素点为单位得到操作栏Z轴的值

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 21. 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 21. 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 21. 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 21. 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 21. 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 21. 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
isHideOnContentScrollEnabled()

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

返回操作栏是否配置为滚动

abstract boolean
isShowing()

abstract ActionBar.Tab
newTab()

This method was deprecated in API level 21. 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 21. 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 21. 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 21. 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 21. 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.

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(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)

This method was deprecated in API level 21. 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 21. 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 21. 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(int resId)

Set the action bar's subtitle.

abstract void
setSubtitle(CharSequence subtitle)

Set the action bar's subtitle.

abstract void
setTitle(int resId)

Set the action bar's title.

abstract void
setTitle(CharSequence title)

Set the action bar's title.

abstract void
show()

Show the ActionBar if it is not currently showing.

更多相关文章

  1. Android中TabHost部件使用
  2. Android(安卓)查看内存使用情况
  3. 【转】Android获取用于操作数据库的SQLiteDatabase实例【学习记
  4. AndroidManifest.xml文件详解(uses-sdk)
  5. taintDroid系统性能测试之——Android(安卓)AVD命令行使用
  6. Android(安卓)inject input events 注入Touch 点(x, y) 触摸输入
  7. 箭头函数的基础使用
  8. NPM 和webpack 的基础使用
  9. Python list sort方法的具体使用

随机推荐

  1. Android(安卓)用户偏好设置,SharedPrefere
  2. 让View只显示下边框
  3. Android Jetpack系列之Lifecycle组件(一篇
  4. Android - ToolBar详解
  5. Android ADB常用命令以及环境配置
  6. 如何把自己规划成高级android开发工程师?
  7. Android常用adb命令总结(一)
  8. Android 实现语音识别
  9. android开发中如何获得应用的数字签名
  10. android 菜单例子