Alex Smith Alex Smith - 1 year ago 125
Android Question

How to change SearchView elements' color?

I want to use SearchView in my project, but I have a problem with elements' color. Let me show you: its fragmentDialog where I have my SearchView
You can see what I mean here
I dont need to change bg color. The next picture is for example. I want to see SearchView elements without black bg.
The color of the elements is white
I have tried to

  • change theme

  • change style

  • change tint

but nothing is working. The search icon and anoter elements still white. Maybe I'm losing something? Can I do this in XML? Please, help me.

Answer Source

You need to use

try with this style in your searchview, Before expanding searchview

After expanding searchview

< xmlns:android=""
            android:layout_gravity="end" />

<style name="SearchViewStyle" parent="Widget.AppCompat.SearchView">
    <!-- Gets rid of the search icon -->
    <item name="searchIcon">@drawable/ic_search</item>
    <!-- Gets rid of the "underline" in the text -->
    <item name="queryBackground">@color/white</item>
    <!-- Gets rid of the search icon when the SearchView is expanded -->
    <item name="searchHintIcon">@null</item>
    <!-- The hint text that appears when the user has not typed anything -->
    <item name="queryHint">@string/search_hint</item>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download