更改操作栏标题颜色 [英] Change Action Bar Title color

查看:153
本文介绍了更改操作栏标题颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的code是如下,虽然它的工作原理(当我改变父主题为Theme.Sherlock或Theme.Sherlock.Light它确实改变了主题),它并没有改变标题颜色。

在code是pretty的大致相同这里

code:

 < XML版本=1.0编码=UTF-8&GT?;
<资源>

<样式名称=MyTheme的父=@风格/ Theme.Sherlock>
 <项目名称=actionBarStyle> @风格/ MyTheme.ActionBarStyle< /项目>
 <项目名称=机器人:actionBarStyle> @风格/ MyTheme.ActionBarStyle< /项目>
< /风格>

<样式名称=MyTheme.ActionBarStyle父=@风格/ Widget.Sherlock.ActionBar>
     <项目名称=机器人:titleTextStyle> @风格/ MyTheme.ActionBar.TitleTextStyle< /项目>
< /风格>

<样式名称=MyTheme.ActionBar.TitleTextStyle父=@风格/ TextAppearance.Sherlock.Widget.ActionBar.Title>
     <项目名称=机器人:文字颜色>#FF0000< /项目>
< /风格>

< /资源>
 

解决方案

从杰克沃顿商学院的ActionBarSherlock网站:

镜像属性

  

由于Android的主题化系统中的任何主题的限制   自定义必须在两个属性来声明。正常   android- prefixed属性应用主题本机操作栏   和pfixed联合国$ P $属性的自定义实现。

后来换的 MyTheme.ActionBarStyle 的为:

 <样式名称=MyTheme.ActionBarStyle父=@风格/ Widget.Sherlock.ActionBar>
     <项目名称=机器人:titleTextStyle> @风格/ MyTheme.ActionBar.TitleTextStyle< /项目>
     <项目名称=titleTextStyle> @风格/ MyTheme.ActionBar.TitleTextStyle< /项目>
   < /风格>
 

现在的标题文字颜色发生了变化。

My code is as below and while it works ( when I change the parent Theme to Theme.Sherlock or Theme.Sherlock.Light the Theme it does changes) it does not changes the Title color.

The code is pretty much the same as here

Code :

<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="MyTheme" parent="@style/Theme.Sherlock">
 <item name="actionBarStyle">@style/MyTheme.ActionBarStyle</item>
 <item name="android:actionBarStyle">@style/MyTheme.ActionBarStyle</item>
</style>

<style name="MyTheme.ActionBarStyle" parent="@style/Widget.Sherlock.ActionBar">
     <item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>

<style name="MyTheme.ActionBar.TitleTextStyle" parent="@style/TextAppearance.Sherlock.Widget.ActionBar.Title" >
     <item name="android:textColor">#FF0000</item>
</style>

</resources>

解决方案

From Jake Wharton's ActionBarSherlock site :

Mirrored Attributes

Due to limitations in Android's theming system any theme customizations must be declared in two attributes. The normal android-prefixed attributes apply the theme to the native action bar and the unprefixed attributes are for the custom implementation.

Had to change MyTheme.ActionBarStyle to :

   <style name="MyTheme.ActionBarStyle" parent="@style/Widget.Sherlock.ActionBar">
     <item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
     <item name="titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
   </style>

Now the Title text color has changed.

这篇关于更改操作栏标题颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆