How do I change the background color of the ActionBar of an ActionBarActivity using XML?
Details:
I'm extending ActionBarActivity.
Eclipse and SDK fully patched as of 2011-11-06.
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14" />
Deployed to Samsung device with Android 2.3.3
Application has android:theme="@android:style/Theme.Light"
Issue: application is light, but ActionBar is blue with grey icons, hardly visible against the blue background color. I also want the ActionBar to be light, so they grey icons are more visible.
I've tried modifying the styles but to no avail.
I'm probably missing something trivial.
How do I change the background color of the ActionBar of an ActionBarActivity using XML ?
Solution 1:
As per documentation - "You can control the behaviors and visibility of the action bar with the ActionBar APIs, which were added in Android 3.0 (API level 11)."
So, ActionBar will not work for your target environment which is at API level 10 (Android 2.3.3).
Just in case, if you target for minimum API level 11 , you can change ActionBar's background color by defining custom style, as:
<resources>
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">ANY_HEX_COLOR_CODE</item>
</style>
</resources>
And, set "MyTheme" as theme for application / activity.
Solution 2:
Try this
ActionBar bar = getActionBar();
bar.setBackgroundDrawable(new ColorDrawable("COLOR"));