1. 介绍
ActionBarSherlock 是Android compatibility library 的一个扩展, 不知道什么原因 Android 兼容开发包没有包含ActionBar. 所以就有了ActionBarSherlock . 其使用方式和 兼容开发包类似。
ActionBarSherlock 被设计成通过一个API就能够很方便使用所有版本的Android操作栏的设计模式。
2.相关网址
其官方网址为:http://actionbarsherlock.com/
github上的地址为:https://github.com/github/android
3.ActionBar的介绍
ActionBarSherlock 是ActionBar的扩展,其实是向下兼容的包。所以要学习ActionBarSherlock ,必须要先学习ActionBar。
学习ActionBar最好的地方是官网的资料,地址如下:http://developer.android.com/guide/topics/ui/actionbar.html
个人觉得一定要把这篇文字完整的看一遍,是最好的ActionBar的学习资料。
我摘点重要的说明:
Figure 1. An action bar that includes the [1] app icon, [2] two action items, and [3] action overflow.
这段说了ActionBar的组成。由 一个应用图标,两个动作的item,和一个溢出的动作 组成。
The action bar provides several key functions: Provides a dedicated space for giving your app an identity and indicating the user's location in the app. Makes important actions prominent and accessible in a predictable way (such as Search). Supports consistent navigation and view switching within apps (with tabs or drop-down lists).
这段说了ActionBar的几个重要的作用:
1.提供一个直接的显示告诉用户他在当前app的位置。
2.给一些重要的操作提供一个直接的方式(例如:搜索)。
3.使整个应用的导航栏的整体风格一致。
4.showAsAction的介绍
在使用ActionBar的时候经常要设置showAsAction,这个属性很重要,设置的不准确可能就显示不出来Action Item.
参考这篇文章的介绍:http://blog.csdn.net/yuxlong2010/article/details/9299507
showAsAction属性共有五个值:ifRoom、never、always、withText、collapseActionView,可以混合使用。
ifRoom |
会显示在Item中,但是如果已经有4个或者4个以上的Item时会隐藏在溢出列表中。当然个数并不仅仅局限于4个,依据屏幕的宽窄而定(当出现在溢出列表中的时候,可以按menu键弹出,但是只有文字没有相应的icon) |
never |
永远不会显示。只会在溢出列表中显示,而且只显示标题,所以在定义item的时候,最好把标题都带上。 |
always | 无论是否溢出,总会显示。 |
withText |
withText值示意Action bar要显示文本标题。Action bar会尽可能的显示这个 |
collapseActionView |
声明了这个操作视窗应该被折叠到一个按钮中,当用户选择这个按钮时,这个操作视窗展开。否则, |
ActionBarSherlock学习笔记二:http://www.cnblogs.com/hsx514/p/3600815.html