Question

I followed the Google's tutorial for changing the color of the Action Bar and wrote the code shown below, but the Action Bar still shows up as per the Holo Light theme.

styles.xml:

    <style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light">

    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar">

    <!-- Support library compatibility -->
    <item name="background">@color/yellow</item>
</style>

Android Manifest:

    <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.AppCompat.Light" >
    <activity
        android:name="com.example.labside.MainActivity"
        android:label="@string/app_name"
        android:theme="@style/CustomActionBarTheme" >

The colors.xml has yellow defined as #FFFF00. Please let me know what I am doing wrong as this whole stuff about Action Bar styling with support for API level 8 is starting to get very confusing! As always, many thanks for all your help!! :)

Was it helpful?

Solution

What android version are you using? Take a look at this post: custom style action bar not working in android 4

Following this post, you need to declare your custom style twice. It looks like you are missing the declaration with the android: prefix.

So I guess, you'll have to add:

<item name="android:background">@color/yellow</item>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top