ActionBar始终使用其中的图标扩展SearchView [英] ActionBar always expanded SearchView with the icon inside
本文介绍了ActionBar始终使用其中的图标扩展SearchView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有SearchView的ActionBar.
I have an ActionBar with a SearchView.
我希望搜索视图始终处于打开"状态(展开).使用
I want the search view to always be "open" (expanded). Doing that is possible using
mSearchView.setIconifiedByDefault(false);
但是由于某种原因,它会将搜索图标移到了文本区域之外:
But it for some reason moves the search icon outside of the text area:
如果我不使用 setIconifiedByDefault(),它看起来像是我希望它在展开时显示的样子:
If I don't use setIconifiedByDefault(), it looks like I want it to look when it is expanded:
但是随后它折叠成背面的搜索图标,并且
But then it collapses into a search icon on back, and also
MenuItemCompat.expandActionView(searchItem);
似乎没有帮助.
有没有办法实现我想要的?
Is there a way to achieve what I want?
推荐答案
您可以拦截OnClose事件:
You can just intercept OnClose event:
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
return true;
}
});
这篇关于ActionBar始终使用其中的图标扩展SearchView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文