2

I'm trying to change the background color of my Actionbar, but after referencing the several other questions on this site I still can't get their solutions to work.

Styles.xml

<resources>

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="actionBarStyle">@style/ActionBar</item>
        <item name="android:windowActionBar">true</item>
    </style>

    <style name="ActionBar" parent="Widget.AppCompat.ActionBar.Solid">
        <item name="background">@color/light_blue_menu_bar</item>
    </style>
</resources>

colors.xml

<resources>
    ... 
    <color name="blue_semi_transparent_pressed">#80738ffe</color>
    <color name="light_blue_menu_bar">#87CEFA</color>
</resources>

manifest.xml

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

However the ActionBar doesn't appear in of my views. What am I missing?

EDIT

The solution was to add to styles.xml

<item name="android:windowActionBar">true</item>

enter image description here

Community
  • 1
  • 1
idclark
  • 948
  • 1
  • 8
  • 27

3 Answers3

1
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/ActionBarStyle</item>
    <item name="actionBarStyle">@style/ActionBarStyle</item>
    <item name="android:windowActionBar">true</item>
</style>

<style name="ActionBarStyle" parent="Widget.AppCompat.ActionBar">
        <item name="background">@color/blue</item>
    <item name="android:background">@color/blue</item>
</style>
Yousef Zakher
  • 1,634
  • 15
  • 18
  • I updated my question to include the relevant part of my manifest.xml. I'm primarily using fragments, but my main activity does extend ActionBarActivity. – idclark May 14 '15 at 01:25
  • 1
    What about activity tag theme? are you sure you are not using getActionBar().hide(); or requestWindowFeature(Window.FEATURE_NO_TITLE); also try true in AppTheme – Yousef Zakher May 14 '15 at 02:08
  • adding true will cause the ActionBar to appear, but it is the default Dark theme, not the light blue that I configured in the styles.xml – idclark May 14 '15 at 02:42
  • that change also generates the dialogue "Rendering Problems. Missing Styles. Is this the correct theme for the chosen layout? Use the theme combo box above the layout to choose a different layout... failed to find style with id 0x7fff0002 in current them" – idclark May 14 '15 at 02:51
  • So we fix the first issue to show your action bar i will edit the answer to show you full example how to set your color, – Yousef Zakher May 14 '15 at 11:17
  • Please upload another screen shot because i don't recognize pop up problem – Yousef Zakher May 14 '15 at 11:25
1

You can use this,

getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#Color_Code")));
Exigente05
  • 2,161
  • 3
  • 22
  • 42
0

Maybe you should edit styles.xml at values-v14 folder.Because your min version is 19.

Cbibejs
  • 91
  • 4