Change the Backgrounds of an ActionBar and SearchView

I tried to use the Holo Light theme with dark action panels, as recommended in the Android manuals. .

This is my themes.xml file:

<resources> <style name="Theme.MyApp" parent="@android:style/Theme.Holo.Light"> <item name="android:actionBarStyle">@style/Widget.MyApp.ActionBar</item> </style> <style name="Widget.MyApp.ActionBar" parent="@android:style/Widget.Holo.ActionBar"> <item name="android:background">@android:drawable/dark_header</item> <item name="android:titleTextStyle">@style/MyApp.ActionBar.TextAppearance</item> </style> <style name="MyApp.ActionBar.TextAppearance" parent="@android:style/TextAppearance"> <item name="android:textColor">@android:color/primary_text_dark</item> </style> </resources> 

The result without using the search interface is expected, but when I use the SearchView background from the Holo.Light theme:

Correct resultIncorrect background

Is there a way to change the default style of SearchView to ActionBar?

+7
source share
2 answers

Looks like this could be your answer:

How to keep the background of ActionBar elements the same ...

In a nutshell:

Try replacing

<item name="android:background">@android:drawable/dark_header</item> with

<item name="android:windowBackground">@android:drawable/dark_header</item>

0
source

This link is most useful for creating an action bar theme in android. This is also good for you.

You just need to create and save the xml files and put them in the appropriate folder.

Thanks.

0
source

All Articles