随着ActionbarSherlock库,如何才能让自定义操作栏 [英] With ActionbarSherlock library, how can I make customized action bar
问题描述
我已经成功导入 ActionbarSherlock 库我自己的项目,我已经可以看到福尔摩斯做出行动酒吧在我的应用程序,当我跑我的项目。
I have successfully imported ActionbarSherlock library to my own project, and I can already see the sherlock made action bar in my application when I run my project.
但是现在,一切都默认。我怎样才能让一个自定义操作栏是福尔摩斯库?任何教程可用?
But, now, everything is by default. How can I make a custom action bar with sherlock library ? Any tutorials available?
推荐答案
我从来没有使用了 ActionBarSherlock
库(我用的Greendroid 过去,但现在我使用 ActionBarCompat 为pre-蜂窝设备,这是伟大的,非常容易使用)。
I have never used the ActionBarSherlock
library (I have used Greendroid in the past, but now I use ActionBarCompat for pre-honeycomb devices, which is great and very easy to use.).
话虽这么说,我建议你找一个在 RES /值
文件夹,你可能会发现所有的默认样式(可能是包裹在它扩展了自定义主题默认的Android主题)。从那里,你就必须延长夏洛克主题,覆盖的风格与自己的。
That being said, I suggest you to look a the res/values
folder where you will probably find all the default styles (probably wrapped in a custom theme which extends the default android theme). From there, you just have to extend that Sherlock theme and override the styles with your own.
如果你想在风格和主题是如何在Android中工作的一个很好的教程,我建议你阅读官方文档。
If you want a good tutorial on how styles and themes work in Android, I suggest you to read the official documentation.
修改
为了使用 ActionBarCompat
,你必须做到以下几点:
In order to use ActionBarCompat
you have to do the following:
- 导入项目从样本目录(安装了Android SDK目录内)。 (请注意,你应该下载最新的SDK)。
- 从构建路径中删除
MainActivity
(右键点击类 - >构建路径 - >排除) 。 - 将项目作为一个项目库(右键点击项目 - >属性 - > Android的 - >检查的是库的) 。
- 添加这个项目,作为您的应用程序库(右该项目点击 - >属性 - > Android的 - >单击添加在库部分) 。
- 请您从活动
ActionBarActivity
继承。 - 将主题定为
@风格/ appTheme
在清单。
- Import the project from the samples directory (inside the directory where the android SDK is installed). (Note that you should download the latest SDK).
- Remove
MainActivity
from the build path (right click on the class -> Build Path -> Exclude). - Set the project as a project library (right click on the project -> properties -> android -> check Is Library).
- Add this project as a library for your app (right click on the project -> properties -> android -> click on Add in the Library section).
- Make your activities inherits from
ActionBarActivity
. - Set the theme as
@style/appTheme
in the manifest.
最后,不要忘了操作栏的动作都在 RES /菜单/ main.xml中
文件。在颜色和款式和同样的事情,看 RES /值
目录
Finally, don't forget that the action bar actions are in the res/menu/main.xml
file. And same thing for the colors and styles, look at the res/values
directory.
这篇关于随着ActionbarSherlock库,如何才能让自定义操作栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!