How to change SearchView default icon?

jmhostalet picture jmhostalet · Jan 16, 2013 · Viewed 30.7k times · Source

I've used "Android Action Bar Style Generator" in order to generate my own Holo theme. Then I've added two icons to the action bar, one for a searchFilter and one for a file picker, both icons are white. File picker icon (at the right) looks good, but somehow search icon looks dark grey. When typing on the search text view, close button also looks dark grey.

I've tried changing color of the actionbar and also from the searchview, without success. Why is the search view showing this color? How can I change it?

ActionBar with two actions

Thank you very much.

UPDATE: I thought that my app was using my icon but it doesn't, it uses the default search view icon, so my question actually is, how do I change the default icon of the search view? This sentence at the menu.xml file is not working:

android:icon="@drawable/selectable_header_search"

Answer

Matthias Robbers picture Matthias Robbers · Jan 17, 2013

Unfortunately, there is no easy way to change the SearchView icon to a custom drawable, since the theme attribute searchViewSearchIcon is not public. See this answer for details.

However, I think that your problem is caused by inheriting from the wrong theme. Please use android:Theme.Holo.Light.DarkActionBar as the base for your theme. Then the default icons on the action bar should have a light color.

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
    ...
</style>