how can we change the title text color of customactionbar in android?

47 views Asked by At

here is my styles.xml file. Can you please tell me how can i change the title text color of the actionbar. By default text is been show as Black color.

styles.xml

<!--
    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="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:background" >@color/MyColor</item>
    <item name="background">@color/MyColor</item>
</style>

<style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light">
    <item name="android:actionBarStyle" >@style/MyActionBar</item>
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>

1

There are 1 answers

0
Rajan Bhavsar On

Ok I've found a better way. I'm now able to only change the color of the title, you can also tweak the subtitle.

Here is my 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 name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textColor">@color/red</item>

</resources>