Skip to content
Advertisement

SearchView icon shows twice

I’ve implemented SearchView inside my toolbar, following Android’s official instructions.

SearchView works well itself, but when I tap the search icon, it is shifted to the left instead of showing the Search Hint and Close button, although if I click this “second Search” icon, finally I get the typical search view.

Here is my xml of the toolbar:

JavaScript

And my onCreateOptionsMenu

JavaScript

And my manifest.xml

JavaScript

Finally, here you have some screenshots of the problem: SearchView before tapping

SearchView after first tap, Here’s the problem

SearchView after second tap, “the normal SearchView”

And that’s all.

Note: I haven’t implemented an Activity/Fragment to handle the Search yet.

Advertisement

Answer

Finally, I got the solution. It was easy, but I’ve spent two days trying to figure it out.

Just, for compatibility issues, use

JavaScript

instead of app:actionViewClass="android.widget.SearchView"

and, of course, change

JavaScript

by

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement