问题
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>
回答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>
回答2:
You can use this,
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#Color_Code")));
回答3:
Maybe you should edit styles.xml at values-v14 folder.Because your min version is 19.
来源:https://stackoverflow.com/questions/30227516/android-unable-to-change-background-color-of-actionbar