[英]Change ActionBar text color
I want to change my ActionBar color to blue (#0c01e3). 我想将ActionBar颜色更改为蓝色(#0c01e3)。 My code is working because the actionbar background property is doing its job.
我的代码正在运行,因为actionbar后台属性正在执行其工作。 But the text won't change.
但文本不会改变。 Any ideas?
有任何想法吗? I'm using ABS.
我正在使用ABS。
<style name="MyActionBar1" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="android:backgroundSplit">#06e301</item>
<item name="android:backgroundStacked">#06e301</item>
<item name="android:background">#06e301</item>
<item name="background">#06e301</item>
<item name="backgroundSplit">#B9001F</item>
<item name="android:textColor">#0c01e3</item>
>
: :
Set this in your Java
Page .It works for me 在你的
Java
页面中设置它。它对我有用
ActionBar ab = getActionBar();
ab.setTitle(Html.fromHtml("<font color='#ffffff'>App Name</font>"));
添加此然后尝试
<item name="android:textColor">#ffffff</item>
On the theme, there is an attribute, actionItemTextColor
, which controls this color. 在主题上,有一个属性
actionItemTextColor
来控制这种颜色。
Remember to specify it with and without the android:
prefix when using ActionBarSherlock. 使用ActionBarSherlock时,请记住使用和不使用
android:
前缀来指定它。
To improve on the answer of @IntelliJ Amiya: 为了改善@IntelliJ Amiya的答案:
getActionBar().setTitle(
Html.fromHtml("<font color='" + getResources().getColor(R.color.my_color) + "'>"
+ getString(R.string.title_home) + "</font>"));
If you want to change that using xml ... This is what worked for me ... 如果你想用xml改变它...这对我有用...
<style name="MyActionBar"
parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/titleBarBgColor</item>
<item name="android:titleTextStyle">@style/EldTheme.ActionBar.TitleTextStyle</item>
<item name="android:subtitleTextStyle">@style/EldTheme.ActionBar.TitleTextStyle</item>
<!-- Support library compatibility -->
<item name="background">@color/titleBarBgColor</item>
<item name="titleTextStyle">@style/EldTheme.ActionBar.TitleTextStyle</item>
<item name="subtitleTextStyle">@style/EldTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="EldTheme.ActionBar.TitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/titleBarTextColor</item>
</style>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.