更改操作栏的颜色后,标题消失了我看到的只是一个橙色背景的操作栏,没有文本。如果我删除"动作栏样式"属性,则会出现文本。我想做的只是为标题的文本和向上按钮使用白色。我的风格.xml:
<style name="SprayTheme" parent="Theme.AppCompat.Light">
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar"
parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="background">@drawable/orange_background</item>
<item name="titleTextStyle">@style/MyActionBarTitleText</item>
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
<item name="android:actionMenuTextColor">@color/background_material_light</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText"
parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/material_blue_grey_800</item>
<!-- The textColor property is backward compatible with the Support Library -->
</style>
这是非常基本的解决方案:将父样式更改为
<style name="SprayTheme" parent="Theme.AppCompat.Light.DarkActionBar">
如果您只想要白色文本颜色,则无需提供额外的文本样式。
您可以使用跨度来获得白色标题:
SpannableString title = new SpannableString("ExampleTitle");
title.setSpan(new ForegroundColorSpan(android.R.color.white), 0, title.getLength());
然后:
getActionBar().setTitle(title);