Android – can’t change color of actionBar divider

androidandroid-actionbarintellij-idea

I tried change color of my actionBar divider , but nothing work. I' using android support library v7 for support old devices and custom style, and i also change all action bar drawable, but nothing happend!

<resources>
    <style name="MyTheme" parent="Theme.AppCompat">
        <item name="actionBarStyle">@style/MyActionBar</item>
    </style>

    <style name="MyActionBar" parent = "Widget.AppCompat.ActionBar">
        <item name="background">@drawable/my_action_bar</item>
    </style>
</resources>

And my ide show me strange error in layout , why did i get this error? it's not color value

java.lang.NumberFormatException: Color value '@drawable/abs__ab_transparent_dark_holo' must start with #

Solution: Need to add android namespace if use for api level >= 14 .May be it will be helpful to someone.

Best Answer

It is because the "divider" is an image. It's hardcoded in the Holo theme assets.

Look at platforms/android-19/data/res/drawable-xxhdpi/ab_transparent_dark_holo.9.png

The style is declared here for holo dark.

<style name="Widget.Holo.ActionBar" parent="Widget.ActionBar">
        ...
        <item name="android:background">@android:drawable/ab_transparent_dark_holo</item>
        ...
</style>

It's a background. You will need to change the color in the image and replace the background of your bar. It also needs different sizes for different resolutions.