简体   繁体   English

如何使我的搜索栏覆盖工具栏中的标题?

[英]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.

相关问题 如何隐藏Android应用程序工具栏中的搜索栏? - How to hide the search bar in the toolbar of my Android application? 如何使我的片段适合我的工具栏和底部导航栏并且仍然可以滚动? - How to make my fragment fit between my toolbar and bottom navigation bar and still make it scrollable? 如何用 CustomView 替换工具栏标题 - How to replace Toolbar Title with CustomView 我将如何移动我的蓝色条形图像以覆盖所有灰色区域? - How would I go about moving my blue bar Image to cover all of the gray area? 在OpenGL中,如何使我的天空盒不覆盖我的任何实体? - In OpenGL, how do I make it so that my skybox does not cover any of my entities? 如何在Java SWT Unified ToolBar(OS X)中右对齐搜索栏 - How do I right align a search bar in a Java SWT Unified ToolBar (OS X) 如何在android仪器测试中检查工具栏标题? - How to check Toolbar title in android instrumental test? 如何在Android应用程序中更改工具栏的标题? - How to change the toolbar's title in android app? 如何为工具栏android中的标题设置自定义字体 - How to set a custom font to the title in toolbar android 如何根据标题的长度调整工具栏的大小? - How to Resize the toolbar according to the length of the title?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM