Changing ActionBar and SearchView backgrounds
Asked Answered
D

2

7

I was trying to use the Holo Light theme with dark action bars as recommended on android guidelines.

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 the expected, but when I use the SearchView the background is from Holo.Light theme:

Correct result Incorrect background

There is any way to change the SearchView default style on the ActionBar?

Damask answered 11/4, 2012 at 21:13 Comment(0)
C
0

This looks like it might be your answer:

How do I keep ActionBar items' background 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>

Cadelle answered 17/5, 2012 at 6:20 Comment(0)
C
0

This link is most useful to create theme of actionbar in android. May this one is useful to you also..

You have to just create and save xml files and put in respective folder.

Thank you.

Circumvolution answered 6/6, 2013 at 12:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.