-1

I'm trying to test out changing the colour of the ActionBar, I've followed the answer of this question: How do I change the background color of the ActionBar of an ActionBarActivity using XML? but it's not changing.

AndroidManifest.xml:

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

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="19" />

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppBaseTheme" >
        <activity
            android:name="com.stevesandco.miajournal.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>

</manifest>

style.xml:

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

    <item name="actionBarStyle">@style/MyActionBar</item>
</style>

<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">@color/main_bg</item>

    <item name="background">@color/main_bg</item>
</style>

colors.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="main_bg">#BADA55</color>
</resources>

I've managed to change the colours through code by using setBackgroundDrawable but I prefer it to be in the xml files.

Community
  • 1
  • 1
j.grima
  • 1,831
  • 3
  • 23
  • 45

1 Answers1

0

you should add .Solid at the end of the parent..

<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
   <item name="android:background">@color/main_bg</item>  
</style>

and remove the line from the app base theme...

<item name="actionBarStyle">@style/MyActionBar</item>
Akshay Sharma
  • 418
  • 3
  • 12