How to make SearchView always expanded in android?

ruruma picture ruruma · Jun 9, 2014 · Viewed 28.6k times · Source

I have SearchView in the top of the layout (not in the action bar), is there anyway to force this View to be always expanded (opened)?

If not, i wish to place fancy image near it, is there anyway to make SearchView hide this image when expanded (clicked/expanded)?

Answer

Wakim picture Wakim · Jun 9, 2014

You can use the property android:iconifiedByDefault="false" on XML or set programatically setIconifiedByDefault(false). Acording to the documentation this property set the SearchView expanded like you want.

Take a look at SearchView.setIconifiedByDefault(boolean iconified)