0

I can't seem to figure out how to change the color of the actionbar to white instead of the default black.

<resources>
    <style name="ActionBarOrange" parent="@android:style/Theme.Holo.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
        <item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
    </style>

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

</resources>

Any help?

2 Answers2

0

In this article you will find how to customize ActionBar and more things

http://developer.android.com/guide/topics/ui/actionbar.html#AdvancedStyles

mohammed momn
  • 3,230
  • 1
  • 20
  • 16
0

Just use HTML:

String htmlColor;
Color orange = getResources().getColor(R.color.orange);
int alpha = Color.alpha(orange);
if (alpha == 0)
    htmlColor = String.format(Locale.US, "#%06X", (0xFFFFFF & orange));
else {
    int red = Color.red(orange);
    int green = Color.green(orange);
    int blue = Color.blue(orange);
    if (Build.VERSION >= 18) //KITKAT first provided CSS3 support
        htmlColor = String.format(Locale.US, "rgba(%d,%d,%d,%d)", red, green, blue, alpha);
    else 
        htmlColor = String.format(Locale.US, "#%06X", (0xFFFFFF & Color.argb(0, red, green, blue)));
}

getActionBar()/* or getSupportActionBar() */.setTitle(Html.fromHtml("<font color=\"" + hexColor + "\">" + getString(R.string.app_name) + "</font>"));
Phil
  • 35,852
  • 23
  • 123
  • 164