如何使SearchView始终在android中扩展? [英] How to make SearchView always expanded in android?
问题描述
我在布局的顶部(不是在操作栏中)有SearchView
,是否有什么办法强制将此View
始终展开(打开)?
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)?
如果没有,我希望在其附近放置精美的图像,是否有必要在展开(单击/展开)后使SearchView
隐藏该图像?
If not, i wish to place fancy image near it, is there anyway to make SearchView
hide this image when expanded (clicked/expanded)?
推荐答案
您可以在XML上使用属性android:iconifiedByDefault="false"
或通过编程方式设置setIconifiedByDefault(false)
.根据文档,此属性可根据需要设置SearchView
展开的位置.
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.
看看 SearchView.setIconifiedByDefault(boolean iconified)
这篇关于如何使SearchView始终在android中扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!