3

When using the theme Theme.Sherlock.Light

weird icon

and using a searchable.xml

<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
    android:label="@string/app_name"
    android:hint="@string/location_search_hint"
    android:icon="@drawable/action_search"
 >

</searchable>

I expect the Search icon to take my own @drawable/action_search which is white but it's ignoring it and it takes the one from the light theme.

How would I be able to change that?

Benoit
  • 4,549
  • 3
  • 28
  • 45
  • Would be interesting to know. Have you found a solution for that? – Tobias Reich Jan 03 '13 at 13:12
  • Nop not yet, I think it's an android bug : http://code.google.com/p/android/issues/detail?id=21774&can=5&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars and there's maybe a solution but I haven't tried it http://stackoverflow.com/questions/11085308/changing-the-background-drawable-of-the-searchview-widget – Benoit Jan 04 '13 at 17:30
  • So what happens if you try the solution below? Any error message? Exceptions? – Tobias Reich Jan 14 '13 at 14:00

2 Answers2

1

So well, I think I found a solution for your problem. Add this line to your themes.xml

<item name="searchViewSearchIcon">@drawable/menu_search</item>

There you can "overwrite" the styles like the magnifier icon with your own drawables.

You may also use the other styles like

<item name="searchViewCloseIcon">@drawable/menu_search_close</item>

etc.

Hope this helps, Tobias

Tobias Reich
  • 4,952
  • 3
  • 47
  • 90
0

Note the menu needs to have the collapseActionView attribute

android:showAsAction="ifRoom|collapseActionView"

Source

EDIT:

Actually I found a better solution the Menu can keep the following line:

android:showAsAction="ifRoom"

And the icon for the search need to use the same name as the one from ActionBarSherlock/AppCompat/Native

for app compat it would be abc_ic_menu_share_holo_dark.png

Community
  • 1
  • 1
Benoit
  • 4,549
  • 3
  • 28
  • 45