更改ActionBar和SearchView背景

时间:2012-04-11 21:13:42

标签: android android-theme android-actionbar android-searchmanager

我试图在android guidelines上推荐使用Holo Light主题和暗动作条。

这是我的themes.xml文件:

<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>

不使用搜索界面的结果是预期的,但是当我使用SearchView时,背景来自Holo.Light主题:

Correct result Incorrect background

有什么方法可以更改ActionBar上的SearchView默认样式?

2 个答案:

答案 0 :(得分:0)

这看起来可能是你的答案:

How do I keep ActionBar items' background the same...

简而言之:

  

尝试替换

     

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

     

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

答案 1 :(得分:0)

This link is most useful to create theme of actionbar in android.这个对你也很有用..

您只需创建并保存xml文件并放入相应的文件夹。

谢谢。