How do I keep ActionBar items' background the

2019-07-31 02:16发布

问题:

I am trying to change the background of the app, but when I do the below (sdk 14) the items in the actionbar also change to match the new background color. The actionbar itself has the correct background, but the items in the actionbar do not. I was able to get the actionbarmenuitems to be correct, but the title and search view and home icon and back button all have the background set on the custom theme. What am I doing wrong?

<?xml version="1.0" encoding="utf-8"?>
<resources>
   <style name="Theme.Holo.DarkerBack" parent="@android:style/Theme.Holo.Light.DarkActionBar">
      <item name="android:background">@color/background</item>
      <item name="android:actionBarStyle">@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse</item>
   </style>
</resources>

回答1:

Try replacing

<item name="android:background">@color/background</item>

with

 <item name="android:windowBackground">@color/background</item>