ActionBar中的标题显示为黑色

时间:2014-09-08 10:41:26

标签: android android-styles

我无法找到为什么操作栏中的标题显示为黑色,这只发生在Android 4.1.1的仿真器上,应该是API 15。 这是我的默认styles.xml

<resources>

<!-- Application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

,这是来自values-v15和values-v14

的样式
<resources>

<style name="AppTheme" parent="Theme.AppCompat">
    <item name="android:actionOverflowButtonStyle">@style/OverFlow</item>
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

<!-- Styles -->
<style name="OverFlow" parent="@android:style/Widget.Holo.ActionButton.Overflow">
    <item name="android:src">@drawable/ic_action_about</item>
    <item name="android:textColor">@color/white</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">@drawable/action_bar_background</item>
    <item name="android:textColor">@color/white</item>
</style>

会出现什么问题?

1 个答案:

答案 0 :(得分:1)

试试这个:

<style name="TitleTextColor">
    <item name="android:text">@string/app_name</item>
        <item name="android:textSize">10sp</item>
        <item name="android:textColor">#a23421</item>
</style>

编辑:(新)将它放在styles.XML

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="MyTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyTheme.ActionBarStyle</item>
  </style>

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

  <style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textColor">@color/red</item>
  </style>
</resources>

白色文字:

<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">#f00</item>
    <item name="android:titleTextStyle">@style/MyTextAppearance</item>
</style>

<style name="MyTextAppearance" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textColor">#ffffff</item>
</style>