如何更改片段中的操作栏标题颜色

时间:2015-04-18 07:07:39

标签: android android-fragments android-actionbar styles navigation-drawer

我在Fragment中有一个导航抽屉。我想更改此片段中的操作栏标题颜色。对于所有其他屏幕,我使用自定义操作栏,并在那里工作正常。我还为Action栏标题指定了样式。 这是我的style.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="CustomActionBarTheme"  parent="@android:style/Theme.Holo">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar"
       parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
</style>

 <!-- ActionBar title text -->
<style name="MyActionBarTitleText"   parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textColorPrimary">@color/ActionBar_text</item>
</style>

 <style name="PoppupMenu" parent="android:Widget.PopupMenu">
    <item name="android:popupBackground">@android:color/white</item>
 </style>

1 个答案:

答案 0 :(得分:0)

您想将CustomActionBarTheme的父级更改为@ style / AppTheme

<style name="CustomActionBarTheme"  parent="@stye/AppTheme">

然后将android:textColorPrimary更改为android:textColor

<item name="android:textColor">@color/ActionBar_text</item>