1

I have my menu item using SearchView as below.

<item
    android:id="@+id/action_search"
    android:title="@string/menu_action_search"
    app:showAsAction="ifRoom"
    android:icon="@android:drawable/ic_menu_search"
    app:actionViewClass="android.support.v7.widget.SearchView" />

I wanted my own icon, where the icon should be @android:drawable/ic_menu_search as indicated in my xml. When I run it, it still use back it's default icon.

How could I get my menu icon instead of the default one provided by SearchView?

Update to clarify my question.

If I remove app:actionViewClass="android.support.v7.widget.SearchView", it will then show the android:icon="@android:drawable/ic_menu_search" as per what I wanted.

But if I put app:actionViewClass="android.support.v7.widget.SearchView" up, it will not show android:icon="@android:drawable/ic_menu_search", but replace with whatever the SearchView provided.

I don't want use the icon SearchView provided

Elye
  • 53,639
  • 54
  • 212
  • 474

2 Answers2

4

same as for all icons and images in drawable folder and use android:icon="@drawable/your_icon"

Giteeka Sawlani
  • 465
  • 2
  • 8
0

Try replacing ifroom to always app:showAsAction="always"

Vikash Kumar Verma
  • 1,068
  • 2
  • 14
  • 30
  • Sorry, I'm not asking about why the icon is not shown. The icon is shown, but not the icon I stated. – Elye Jun 15 '16 at 12:28