[置顶] Android--(14)--通过安卓选择器来修改actionbar的样式与字体样式
2017-10-21 13:52
537 查看
一.修改actionbar样式的基本步骤:
1.首先在drawable文件夹下新建一个选择文件select_style.xml备用,代码如下:
selector的常用属性:
android:state_selected : 表示是否为选中状态
android:state_pressed : 表示是否为点击状态
然后根据不同的状态来设定不懂得效果
2.重写actionBarTabStyle属性,然后将它指向一个新建的Tab样式;并在此样式中将background属性指定为刚创建的选择样式;代码如下:
到此样式设置就完成啦;
二.设置字体颜色
重写android:actionBarTabTextStyle属性
将style修改为如下方式:
没啥技术含量,重写某一属性就行
1.首先在drawable文件夹下新建一个选择文件select_style.xml备用,代码如下:
selector的常用属性:
android:state_selected : 表示是否为选中状态
android:state_pressed : 表示是否为点击状态
然后根据不同的状态来设定不懂得效果
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <!-- 未选中未点击 --> <item android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/top_3" /> <!-- 选中未点击 --> <item android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/top_2" /> </selector>
2.重写actionBarTabStyle属性,然后将它指向一个新建的Tab样式;并在此样式中将background属性指定为刚创建的选择样式;代码如下:
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar"> <item name="android:actionBarTabStyle">@style/actionBarStyle</item> </style> <!-- 创建的style样式 --> <style name="actionBarStyle" parent="@android:style/Widget.Holo.ActionBar.TabView"> <item name="android:background">@drawable/select_style</item> </style> </resources>
到此样式设置就完成啦;
二.设置字体颜色
重写android:actionBarTabTextStyle属性
将style修改为如下方式:
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar"> <item name="android:actionBarTabTextStyle">@ ae39 style/actionTextstyle</item> <item name="android:actionBarTabStyle">@style/actionBarStyle</item> </style> <!-- 设置标题Tab的字体样式 --> <style name="actionTextstyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title"> <item name="android:textColor">@drawable/select_text</item> <item name="android:textSize">18sp</item> </style> <!-- 创建的style样式 --> <style name="actionBarStyle" parent="@android:style/Widget.Holo.ActionBar.TabView"> <item name="android:background">@drawable/select_style</item> </style> </resources>
没啥技术含量,重写某一属性就行
相关文章推荐
- Android 修改全局自定义字体样式(字形,大小)※
- android:修改PagerTabStrip中的背景颜色,标题字体的样式、颜色和图标以及指示条的颜色
- 【Android 应用开发】 ActionBar 样式详解 -- 样式 主题 简介 Actionbar 的 icon logo 标题 菜单样式修改
- Android keyboardView字体样式修改
- Android Actionbar学习笔记(三)-----修改Actionbar的样式
- Android WebView通过代码修改网页的字体大小
- 安卓全局修改TextView字体样式
- Android 修改ActionBar样式
- Android 修改TextView字体样式
- 对Android APP的各种样式统一修改方法(这里列举了通知状态栏StatueBar,标题栏ActionBar,ToolBar和按钮Button的样式修改)
- 太激动!Android修改全局字体样式,替换整个APP字体
- android:修改PagerTabStrip中的背景颜色,标题字体的样式、颜色和图标以及指示条的颜色
- Android 开发------------------ 修改 Actionbar 的样式
- Android 开发 Tip 19 -- 修改Menu的字体大小和样式
- [置顶] Android省市区一,二,三联滚动选择器(使用Dialog样式的Activity实现)
- Android Actionbar学习笔记(三)-----修改Actionbar的样式
- android中修改actionbar的背景颜色和字体颜色等
- Android actionbar在Material主题中修改样式
- android:修改PagerTabStrip中的背景颜色,标题字体的样式、颜色和图标以及指示条的颜色
- 【Android 应用开发】 ActionBar 样式详解 -- 样式 主题 简介 Actionbar 的 icon logo 标题 菜单样式修改