android开发training之actionbar之3
来源:互联网 发布:周杰伦演唱会知乎 编辑:程序博客网 时间:2024/04/30 07:01
装饰action bar
一、使用默认的action bar
Android theme有两种theme支持action bar
Theme.Holo
for a "dark" theme.Theme.Holo.Light
for a "light" theme.
可以在<application>
中定义应用的全局theme也可以在<activity>
中单独定义一个activity的theme。例如:
Theme.Holo
for a "dark" theme.Theme.Holo.Light
for a "light" theme.可以在<application>
中定义应用的全局theme也可以在<activity>
中单独定义一个activity的theme。例如:<application android:theme="@android:style/Theme.Holo.Light" ... />
效果如下:
action bar是黑色而其余部分是light color使用Theme.Holo.Light.DarkActionBar
theme.
当使用支持库时,用下面的方法:
When using the Support Library, you must instead use the Theme.AppCompat
themes:
Theme.AppCompat
for the "dark" theme.Theme.AppCompat.Light
for the "light" theme.Theme.AppCompat.Light.DarkActionBar
for the light theme with a dark action bar.
Android3.0及以上:
像下面这样改变action bar的背景色:
<?xml version="1.0" encoding="utf-8"?><resources> <!-- the theme applied to the application or activity --> <style name="CustomActionBarTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar"> <item name="android:actionBarStyle">@style/MyActionBar</item> </style> <!-- ActionBar styles --> <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse"> <item name="android:background">@drawable/orange</item> </style></resources>
在整个app或某个activity中应用主题:
<application android:theme="@style/CustomActionBarTheme" ... />android2.1以下就不指明怎么用了。
三、自定义action bar中文字。
实现如下效果:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/orange</item>
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/actionbar_text</item>
</style>
</resources>
android2.1以下就不指明怎么用了。
四、将action bar变成透明的效果,如下:
Android 3.0以上,自己定制的theme的父theme应该是Theme.Holo
例如:
<resources> <!-- the theme applied to the application or activity --> <style name="CustomActionBarTheme" parent="@android:style/Theme.Holo"> <item name="android:windowActionBarOverlay">true</item> </style></resources>但是会有一个问题,顶部的textview在action bar下面,用下面的方法解决。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="?android:attr/actionBarSize"> ...</RelativeLayout>
http://download.csdn.net/detail/xliubaox/8304183 源代码
- android开发training之actionbar之3
- android开发training之actionbar之2
- android开发training之actionbar之1
- Android文档Training之ActionBar
- Android官方开发文档Training系列课程中文版:添加ActionBar之设置ActionBar
- Android官方开发文档Training系列课程中文版:添加ActionBar之自定义ActionBar样式
- Android官方开发文档Training系列课程中文版:添加ActionBar之ActionBar浮层效果
- Android官方开发文档Training系列课程中文版:添加ActionBar之添加Action按钮
- Android开发之创建ActionBar
- android开发之Android ActionBar完全解析
- ActionBar ——Android UI开发详解之ActionBar
- Android 开发之为ActionBar 添加Actionbar Button
- Android 开发之为ActionBar 添加Actionbar Button
- Android UI开发详解之ActionBar
- Android UI开发详解之ActionBar
- Android UI开发详解之ActionBar
- Android UI开发详解之ActionBar
- Android UI开发详解之ActionBar
- Jquery - JSOn
- hdu 5137 最短路
- cocos2dx相关文章整理
- Unity之EditorWindow-window-一
- spring mvc
- android开发training之actionbar之3
- 逆袭神器,废旧安卓手机做Andriod LAMP网站服务器
- linux awk命令详解
- android 通过handler message 和 timer 实现主界面定时更新
- tokuDB 使用详解及其注意事项(2)
- Google I/O 2014之Android面面观
- sphinx使用篇
- LEETCODE: Word Search
- Linux Shell删除两个文件相同部分