Changing the ActionBar title color of an Android app

1.7k views Asked by At

I have been reading all the already asked questions about this but still I can't make the color of the text in the actionbar change. For the code I pretty much copy/pasted the instructions on the following link: https://developer.android.com/training/basics/actionbar/styling.html#CustomText

<!--theme applied to the application or activity-->
<style name="myActionbarTheme" parent="android:Theme.Holo">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>
    <item name="android:actionMenuTextColor">@color/lightBlue</item>
</style>

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

<!-- actionBar title text -->
<style name="MyActionBarTitleText" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textColor">@color/lightBlue</item>
    <item name="android:textSize">16sp</item>

</style>

<!-- actionBar tabs text styles -->
<style name="MyActionBarTabText" parent="android:Widget.Holo.ActionBar.TabText">
    <item name="android:textColor">@color/lightBlue</item>
</style>

<!--
    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>

The last 2 styles are not used but they might create a conflict i'm not aware of. So that is what I have in the styles.xml, while for the androidmanifest the code is:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.flexenergy.swapp"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Holo.Light" >
    <activity
        android:name="com.flexenergy.swapp.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
<application
    android:allowBackup="true"
    android:theme="@style/myActionBarTheme">

</application>

And the last is the code of color.xml:

<item name="lightBlue" type="color">#00FF00</item>
<integer-array name="androidcolors">
    <item>@color/lightBlue</item>
</integer-array>

I am quite a newbie in this so don't make any assumption of something that should be correct...

Thanks in advance.

1

There are 1 answers

1
CommonsWare On BEST ANSWER

Change android:theme="@android:style/Theme.Holo.Light" in your manifest to android:theme="@style/myActionbarTheme", and get rid of the pointless second <application> element. There is only one <application> element per Android manifest at this time.