[英]How to make my search bar cover the title in the toolbar?
I have a toolbar in my Android application. 我的Android应用程序中有一个工具栏。 I have the activity's title shown in the toolbar.
我的活动标题显示在工具栏中。 I have a search icon and I want to expand it to cover the rest of the toolbar, including the title.
我有一个搜索图标,我想扩展它以覆盖工具栏的其余部分,包括标题。 However, it only covers part of the title.
但是,它仅涵盖标题的一部分。 How to cover the whole part of it?
如何覆盖整个部分?
The code of the search bar: 搜索栏的代码:
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
mSearchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
mSearchView.setIconifiedByDefault(true);
You can set the maximum width of the search bar to be Integer.MAX_VALUE
. 您可以将搜索栏的最大宽度设置为
Integer.MAX_VALUE
。 It will cover the whole part of the title. 它将涵盖标题的整个部分。
mSearchView.setMaxWidth(Integer.MAX_VALUE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.