如何更改操作栏标签文本颜色 [英] How to change the Action bar tab text color
本文介绍了如何更改操作栏标签文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要改变color.So远远操作栏标签的文字颜色black.But显示的操作栏标签的文字,我需要把它变成白色。
清单:
<?XML版本=1.0编码=UTF-8&GT?;<清单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=com.fth.android
安卓版code =1
机器人:=的versionName1.0> <用途-SDK
安卓的minSdkVersion =14
机器人:targetSdkVersion =19/> <用途特征
机器人:名字=android.hardware.touchscreen
机器人:要求=假/> <应用
机器人:名字=com.sit.fth.app.GemsApplication
机器人:allowBackup =真
机器人:图标=@绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME 机器人:主题=@安卓风格/ Theme.Holo.Light>
<活动
机器人:名字=com.sit.fth.activity.SplashActivity
机器人:launchMode =singleTask
机器人:标签=@字符串/ APP_NAME
机器人:screenOrientation =画像
机器人:主题=@安卓风格/ Theme.Black.NoTitleBar.Fullscreen> &所述;意图滤光器>
<作用机器人:名字=android.intent.action.MAIN/> <类机器人:名字=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT; <活动机器人:名字=com.sit.fth.activity.HomeActivity>
< /活性GT; &所述;! - 父活动的元数据,以支持4.0和低级 - >
<活动机器人:名字=com.sit.fth.activity.GalleryActivity>
< /活性GT; <活动机器人:名字=com.sit.fth.activity.AnnouncementActivity>
< /活性GT; <活动机器人:名字=com.sit.fth.activity.MagazineActivity>
< /活性GT; <活动机器人:名字=com.sit.fth.activity.YoutubePlayActivity>
< /活性GT; <活动机器人:名字=com.sit.fth.activity.ContactActivity>
< /活性GT; < /用途>< /清单>
RES /价值/ styles.xml:
<资源的xmlns:机器人=http://schemas.android.com/apk/res/android> <! -
基础应用的主题,依赖于API级别。这个主题被替换
通过AppBaseTheme从RES /值-VXX /较新设备上styles.xml。
- >
<样式名称=AppBaseTheme父=机器人:Theme.Light>
<! -
在新API的级别可以去提供自定义主题
RES /值-VXX / styles.xml,而自定义相关
向后兼容性可以去这里。
- >
< /风格> <! - 应用的主题。 - >
<样式名称=AppTheme父=AppBaseTheme> <! - 所有自定义不特定于一个特定的API级别的可以去这里。 - >
< /风格> <样式名称=网格布局>
<项目名称=机器人:drawSelectorOnTop>真< /项目>
<项目名称=机器人:listSelector> @绘制/ photogrid_list_selector< /项目>
< /风格> <样式名称=CustomRatingBar父=@安卓风格/ Widget.RatingBar>
<项目名称=机器人:progressDrawable> @绘制/ custom_ratingbar< /项目>
<项目名称=安卓了minHeight> 20dip< /项目>
<项目名称=安卓了maxHeight> 20dip< /项目>
< /风格>
<样式名称=CustomTheme父=@安卓风格/主题>
<项目名称=机器人:tabWidgetStyle> @风格/ CustomTabWidget< /项目>
< /风格><样式名称=CustomTabWidget父=@安卓风格/ Widget.TabWidget>
<项目名称=机器人:textAppearance> @风格/ CustomTabWidgetText< /项目>
< /风格><样式名称=CustomTabWidgetText
父=@安卓风格/ TextAppearance.Widget.TabWidget>
<项目名称=机器人:TEXTSIZE>&12SP LT; /项目>
!< - <项目名称=机器人:文字样式>大胆< /项目> - >
< /风格>
< /资源>
在res / color.xml:
<?XML版本=1.0编码=UTF-8&GT?;
<资源>
<绘制NAME =list_bg_normal>#00000f< /绘>
<绘制NAME =list_bg_normal_audio>#ededed< /绘>
<绘制NAME =list_bg_ pressed_audio>#FFFFFF< /绘>
<绘制NAME =list_bg_ pressed>#848484< /绘>
<颜色名称=grid_state_ pressed>#BB7dbcd3< /彩色>
<颜色名称=grid_state_focused>#777dbcd3< /彩色>
<绘制NAME =app_theme_bg>#F5F5FA< /绘> <颜色名称=title_detail_color>#000000< /彩色>
<颜色名称=duration_color>#e4e4e4< /彩色>
<颜色名称=content_color>#454545< /彩色>< /资源>
任何人都可以帮我these.Thank你。</ P>
解决方案
在您的AppTheme声明如下:
&LT;项目名称=机器人:actionBarTabTextStyle&GT; @风格/ tabtextcolor&LT; /项目&GT;
然后这里是样式声明:
&LT;样式名称=tabtextcolor父=@安卓风格/ Widget.Holo.Light.ActionBar.TabText&GT;
&LT;项目名称=机器人:文字颜色&GT; @android:彩色/白色&LT; /项目&GT;
&LT; /风格&GT;
I need to change the Action bar tab text color.So far Action bar tab text color displayed in black.But I need to change it into white color.
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fth.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<application
android:name="com.sit.fth.app.GemsApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo.Light" >
<activity
android:name="com.sit.fth.activity.SplashActivity"
android:launchMode="singleTask"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.sit.fth.activity.HomeActivity" >
</activity>
<!-- Parent activity meta-data to support 4.0 and lower -->
<activity android:name="com.sit.fth.activity.GalleryActivity" >
</activity>
<activity android:name="com.sit.fth.activity.AnnouncementActivity" >
</activity>
<activity android:name="com.sit.fth.activity.MagazineActivity" >
</activity>
<activity android:name="com.sit.fth.activity.YoutubePlayActivity" >
</activity>
<activity android:name="com.sit.fth.activity.ContactActivity" >
</activity>
</application>
</manifest>
res/values/styles.xml:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="GridLayout">
<item name="android:drawSelectorOnTop">true</item>
<item name="android:listSelector">@drawable/photogrid_list_selector</item>
</style>
<style name="CustomRatingBar" parent="@android:style/Widget.RatingBar">
<item name="android:progressDrawable">@drawable/custom_ratingbar</item>
<item name="android:minHeight">20dip</item>
<item name="android:maxHeight">20dip</item>
</style>
<style name="CustomTheme" parent="@android:style/Theme">
<item name="android:tabWidgetStyle">@style/CustomTabWidget</item>
</style>
<style name="CustomTabWidget" parent="@android:style/Widget.TabWidget">
<item name="android:textAppearance">@style/CustomTabWidgetText</item>
</style>
<style name="CustomTabWidgetText"
parent="@android:style/TextAppearance.Widget.TabWidget">
<item name="android:textSize">12sp</item>
<!-- <item name="android:textStyle">bold</item> -->
</style>
</resources>
In res/color.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<drawable name="list_bg_normal">#00000f</drawable>
<drawable name="list_bg_normal_audio">#ededed</drawable>
<drawable name="list_bg_pressed_audio">#FFFFFF</drawable>
<drawable name="list_bg_pressed">#848484</drawable>
<color name="grid_state_pressed">#BB7dbcd3</color>
<color name="grid_state_focused">#777dbcd3</color>
<drawable name="app_theme_bg">#F5F5FA</drawable>
<color name="title_detail_color">#000000</color>
<color name="duration_color">#e4e4e4</color>
<color name="content_color">#454545</color>
</resources>
Anybody can help me with these.Thank you.
解决方案
Declare this in your AppTheme:
<item name="android:actionBarTabTextStyle">@style/tabtextcolor</item>
Then here is the style declaration:
<style name="tabtextcolor" parent="@android:style/Widget.Holo.Light.ActionBar.TabText">
<item name="android:textColor">@android:color/white</item>
</style>
这篇关于如何更改操作栏标签文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文