这个项目的目的是提供一个可重用的操作栏组件。操作栏模式在Android的模式是有据可查的。

操作栏组件是一个图书馆项目。这意味着,有没有需要复制粘贴到自己的项目资源,只需将动作栏组件作为一个参考的任何项目。

需要你的动作条的图标? ,已经移植奥洛夫Brickarp的一些机器人矢量格式的原生图标。http://www.yay.se/2011/02/native-android-icons-in-vector-format/

用法:

在布局中:

<com.markupartist.android.widget.ActionBarandroid:id="@+id/actionbar"app:title="@string/some_title"style="@style/ActionBar"/>

应用程序的使用:标题是可选的,它也有可能在ActionBar编程使用setTitle到指定的标题。为了能够使用更方便的应用程序:在android的命名空间是相同的方式,标题必须包括应用的命名空间。请参阅布局other.xml一个完整的例子在示例项目。再次,要注意它的应用程序的命名空间和动作条的命名空间必须像XMLNS简称:程序=“http://schemas.android.com/apk/res/you.application.package.here”。

在你的Activity:

ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
// You can also assign the title programmatically by passing a
// CharSequence or resource id.
//actionBar.setTitle(R.string.some_title);
actionBar.setHomeAction(new IntentAction(this, HomeActivity.createIntent(this), R.drawable.ic_title_home_default));
actionBar.addAction(new IntentAction(this, createShareIntent(), R.drawable.ic_title_share_default));
actionBar.addAction(new ToastAction());

自定义操作:

ActionBar中自带了一个方便的IntentAction,使得它很容易创建行动的意图。要创建自定义操作,简单地实现了Action接口,并建立你自己喜欢吐司的例子下面。

private class ToastAction implements Action {@Overridepublic int getDrawable() {return R.drawable.ic_title_export_default;}@Overridepublic void performAction(View view) {Toast.makeText(OtherActivity.this,"Example action", Toast.LENGTH_SHORT).show();}}

点击标题处理:

要处理的标题上点击一个android.view.View.OnClickListener传递动作栏上的方法setOnTitleClickListener的。传递的onClick认为是被分配到TextView中的标题。

actionBar.setOnTitleClickListener(new OnClickListener() {public void onClick(View v) {// Your code here}
});

定制:

由于在ActionBar库“项目的所有资源将被合并到项目中,引用在ActionBar。主体工程中的值将始终使用预设值才会在ActionBar。

如果你不喜欢默认的颜色colors.xml的文件中定义的只是覆盖colors.xml的主要项目文件中的默认值。要创建一个蓝色的ActionBar创建一个colors.xml文件看起来像下面的东西的。请注意,我们不重写值actionbar_background_item_pressed_start和actionbar_background_item_pressed_end因为我们决定坚持使用默认值。

<?xml version="1.0" encoding="utf-8"?>
<resources><color name="actionbar_separator">#3A5FCD</color><color name="actionbar_background_start">#3A5FCD</color><color name="actionbar_background_end">#27408B</color>
</resources> 

同样可以做到这样的效果,通过drawables,布局和一切位于ActionBar的项目。

它是稳定的吗?

的确是这样,但谁也不能保证。然而,该API仍然没有稳定,所以请检查所有提交自上次拉动。它也可能是一个好主意,这个组件,而不是直接依赖于您自己的叉子。最终将有更多的控制释放,但在那之前。

您使用的是这个小部件?

要使用它的应用程序在画廊展出?然后,请发送您的应用程序的截图和细节到约翰·尼尔森。

捐款:

这个小工具是不一样的,没有卓越贡献;

ohhorob,https://github.com/ohhorob
denravonska,https://github.com/denravonska
rpdillon,https://github.com/rpdillon
RickardPettersson,https://github.com/RickardPettersson
杰克沃顿商学院,https://github.com/JakeWharton
杰西·文森特,http://blog.fsck.com
Gyuri克雷尔,http://gyurigrell.com

想做出贡献吗?

GitHub上有一些伟大的文章如何开始使用Git和GitHub上,以及如何fork一个项目。

贡献者推荐到餐桌GitHub上的应用程序(但不要有太多)。创建一个特性分支,分支推到git的枢纽,按拉的请求,写一个简单的解释。

每提交一个修复。如果说一个提交关闭打开的问题12。只需添加关闭#12你的提交信息自动的关闭问题。

所有贡献的代码必须符合Apache许可证2.0。

代码风格指引:

贡献者建议遵循了Android的代码风格指引线的长度,我尝试持有至80列,在可能的情况下例外。

总之;

缩进4个空格,没有标签。
线路长度:80列
字段名称:非公开,非静态字段以m开始。
括号:开放括号不要去上自己的行。
缩略语词:治疗词语的名字的首字母缩写,产生的XmlHttpRequest中,getURL()等
一致性:看看你周围的什么!
玩得开心,还记得我们在课余时间,所以不要太严重了:)

许可证:

版权所有(c)2010约翰·尼尔森

根据Apache许可证2.0版授权

以下为英文原文:

This projects aims to provide a reusable action bar component. The action bar pattern is well documented atAndroid Patterns.

The action bar component is an Library Project. This means that there's no need to copy-paste resources into your own project, simply add the action bar component as a reference to any project.

Need icons to your action bar? Olof Brickarp has ported some of Androids native icons to vector format.

Usage

In your layout

<com.markupartist.android.widget.ActionBarandroid:id="@+id/actionbar"app:title="@string/some_title"style="@style/ActionBar"/>

The use of app:title is optional, it's also possible to assign the title using the setTitle programmatically on the ActionBar. To be able to use the more convenient app:title the application namespace must be included in the same manner as the android namespace is. Please refer to the layout other.xml in the example project for a full example. Again, note that it's the application namespace and not the actionbar namespace that must be referred like xmlns:app="http://schemas.android.com/apk/res/you.application.package.here".

In your activity

ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
// You can also assign the title programmatically by passing a
// CharSequence or resource id.
//actionBar.setTitle(R.string.some_title);
actionBar.setHomeAction(new IntentAction(this, HomeActivity.createIntent(this), R.drawable.ic_title_home_default));
actionBar.addAction(new IntentAction(this, createShareIntent(), R.drawable.ic_title_share_default));
actionBar.addAction(new ToastAction());

Custom actions

ActionBar comes with a convenient IntentAction that makes it easy to create action out of Intents. To create custom actions simply implement the Action interface and build your own like the Toast example below.

private class ToastAction implements Action {@Overridepublic int getDrawable() {return R.drawable.ic_title_export_default;}@Overridepublic void performAction(View view) {Toast.makeText(OtherActivity.this,"Example action", Toast.LENGTH_SHORT).show();}}

Handle on click on the title

To handle on clicks on the title pass a android.view.View.OnClickListener to the methodsetOnTitleClickListener on the action bar. The View that is passed in onClick is the TextView that the title is assigned to.

actionBar.setOnTitleClickListener(new OnClickListener() {public void onClick(View v) {// Your code here}
});

Customization

Since the ActionBar is an Libary Project all resources will be merged to the project that referencing the ActionBar. The values in the main project will always be used before the default values of the ActionBar.

If you don't like the default colors that is defined in the colors.xml file simply override the default values in the main projects colors.xml file. To create a blue ActionBar create a colors.xml file that looks something like the one below. Note that we don't override the values for actionbar_background_item_pressed_start andactionbar_background_item_pressed_end since we decided to stick with the default values.

<?xml version="1.0" encoding="utf-8"?>
<resources><color name="actionbar_separator">#3A5FCD</color><color name="actionbar_background_start">#3A5FCD</color><color name="actionbar_background_end">#27408B</color>
</resources>

The same can be done with the drawables, layouts and everything else that is located in the ActionBar project.

Is it stable?

Yes it is, but there's no guarantees. The api however is still not stable so please check all commits since the last pull. It might also be an good idea to depend on your own fork instead of this component directly. Eventually there will be more controlled releases but until then.

Are you using this widget?

Want to be featured in a gallery of apps using it? Then please send a screenshot and details of your app to Johan Nilsson.

Contributions

This widget wouldn't be the same without the excellent contributions by;

  • ohhorob, https://github.com/ohhorob
  • denravonska, https://github.com/denravonska
  • rpdillon, https://github.com/rpdillon
  • RickardPettersson, https://github.com/RickardPettersson
  • Jake Wharton, https://github.com/JakeWharton
  • Jesse Vincent, http://blog.fsck.com
  • Gyuri Grell, http://gyurigrell.com

Want to contribute?

GitHub has some great articles on how to get started with Git and GitHub and how to fork a project.

Contributers are recommended to fork the app on GitHub (but don't have too). Create a feature branch, push the branch to git hub, press Pull Request and write a simple explanation.

One fix per commit. If say a a commit closes the open issue 12. Just add closes #12 in your commit message to close that issue automagically.

All code that is contributed must be compliant with Apache License 2.0.

Code Style Guidelines

Contributers are recommended to follow the Android Code Style Guidelines with exception for line length that I try to hold to 80 columns where possible.

In short that is;

  • Indentation: 4 spaces, no tabs.
  • Line length: 80 columns
  • Field names: Non-public, non-static fields start with m.
  • Braces: Opening braces don't go on their own line.
  • Acronyms are words: Treat acronyms as words in names, yielding XmlHttpRequest, getUrl(), etc.
  • Consistency: Look at what's around you!

Have fun and remember we do this in our spare time so don't be too serious :)

License

Copyright (c) 2010 Johan Nilsson

Licensed under the Apache License, Version 2.0

Action Bar for Android相关推荐

  1. android action bar 风格,Android ActionBar使用教程

    ActionBar的引入方式: 有几种,从 Android 3.0(API lever 11) 开始,所有使用 Theme.Holo 主题(或者它的子类)的 Activity 都包含了 action ...

  2. Android UI开发第二十五篇——分享一篇自定义的 Action Bar

    Action Bar是android3.0以后才引入的,主要是替代3.0以前的menu和tittle bar.在3.0之前是不能使用Action Bar功能的.这里引入了自定义的Action Bar, ...

  3. android如何在底部显示四个按钮,[Android系列—] 四. 添加操作栏(Action Bar)

    [Android系列-] 4. 添加操作栏(Action Bar) 前言 操作栏是最重要的设计元素之一,使用它来实现你的应用程序活动.通过提供多种用户界面功能, 使应用程序快速和其他的Andorid应 ...

  4. Android Action Bar 详解篇

    作为Android 3.0之后引入的新的对象,ActionBar可以说是一个方便快捷的导航神器.它可以作为活动的标题,突出活动的一些关键操作(如"搜索"."创建" ...

  5. 【Android Developers Training】 6. 配置Action Bar

    注:本文翻译自Google官方的Android Developers Training文档,译者技术一般,由于喜爱安卓而产生了翻译的念头,纯属个人兴趣爱好. 原文链接:http://developer ...

  6. android action bar 风格,自定义ActionBar的风格

    如果想将 action bar 的风格设计的合乎我们产品的定位,只需简单地使用 Android 的样式和主题资源. 注意:如果我们为 action bar 使用了 Support 库的 API,那我们 ...

  7. 【Android Developers Training】 8. 定义Action Bar风格

    注:本文翻译自Google官方的Android Developers Training文档,译者技术一般,由于喜爱安卓而产生了翻译的念头,纯属个人兴趣爱好. 原文链接:http://developer ...

  8. android switch控件的大小,关于Android Action Bar 上的 Switch控件

    是这样的: 因为要在Action Bar 上弄个 Switch 按钮,所以我照 http://stackoverflow.com/questions/12107031/how-to-add-a-swi ...

  9. 连Action Bar都不会 你能说你学过 Android?

    本文原创首发CSDN,链接 https://blog.csdn.net/qq_41464123/article/details/106605555 ,作者博客https://blog.csdn.net ...

最新文章

  1. 【软件工程】RUP与软件开发5大模型
  2. 防止apche列出目录以及下载文件
  3. 八十八、Python | 十大排序算法系列(下篇)
  4. 虚拟机的分类_虚拟化精华问答 | 虚拟化技术分类
  5. pycharm 中HTML代码的对齐
  6. 计算机科学1pdf,计算机科学导论1.pdf
  7. the development of c language(转)
  8. fcpx大胆流行标题插件 Bold Pop for mac
  9. 博客园博客转至个人网站博客声明
  10. win7 自带计算机(for programmer)
  11. spark安装及环境配置(win10)
  12. 毫米波雷达信号处理系统
  13. php聊天功能界面,php实现聊天室功能完整代码
  14. PostgreSQL 连接(JOIN)
  15. qos cbs_如何取消CBS所有访问订阅
  16. 如何正确选择注塑模具浇口位置?这下真的懂了
  17. 随机数函数rand()
  18. linux连接mssql数据库,在Centos7下为PHP安装mssql扩展
  19. python元素分类_在python中对列表的元素进行分类
  20. vue.js 2 引导 (maybe it is a whiny posts)

热门文章

  1. CDH6.3.2之Kafka配置和命令
  2. css+文字排在底部,css怎么让文字居于div的底部
  3. js添加多个子节点_在js中添加新节点
  4. py3环境bytes转换unicode注意
  5. 【52ABP实战教程】0.2-- VSTS中的账号迁移到东亚
  6. 【shell脚本】修改ssh端口
  7. C#调用socket 后出现配置系统未能初始化的问题解决方法
  8. 从校园到职场,听听他们的成长之路
  9. 浅谈质量方案中的预案
  10. java 富文本html 转 word(带图片处理