Details:
I\'m extending ActionBarActivity.
Eclipse and SDK fully patched as of 2011-11-06.
On the Nexus 4 people this seems to make the color go grey.
ActionBar bar = getActionBar(); // or MainActivity.getInstance().getActionBar()
bar.setBackgroundDrawable(new ColorDrawable(0xff00DDED));
bar.setDisplayShowTitleEnabled(false); // required to force redraw, without, gray color
bar.setDisplayShowTitleEnabled(true);
(all credit to this post, but it is buried in the comments, so I wanted to surface it here) https://stackoverflow.com/a/17198657/1022454
Use below code to provide different color to actionbar text and actionbar background just use below theme in manifest against the activity in which you want output :)
<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:titleTextStyle">@style/TitleBarTextColor</item>
<item name="android:background">YOUR_COLOR_CODE</item>
</style>
<style name="TitleBarTextColor" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">YOUR_COLOR_CODE</item>
</style>
This worked for me, for AppCompatActivity,
<item name="actionBarStyle">@style/BlackActionBar</item>
</style>
<style name="BlackActionBar" parent="@style/Widget.AppCompat.ActionBar.Solid">
<item name="background">@android:color/black</item>
<item name="titleTextStyle">@style/BlackActionBarTitleTextStyle</item>
</style>
<style name="BlackActionBarTitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@android:color/white</item>
<item name="android:fontFamily">@font/cinzel_decorative</item>
</style>
Its very simple for those who are using API 21 or greater Use this code below
<resources>
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:background">@color/colorDarkGrey</item>
</style>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.ActionBar">
<item name="android:background">@color/colorDarkGrey</item>
</style>
Use this, it would work.
ActionBar actionbar = getActionBar();
actionbar.setBackgroundDrawable(new ColorDrawable("color"));
getActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.TabColor)));
color.xml file:
<resources> <color name="TabColor">#11FF00</color> </resources>`