当处于横向时,StatusBar中的搜索工具会完全更改。
只有在展开搜索栏时才会发生这种情况。
修改
CODE:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.action_menu, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
int options = searchView.getImeOptions();
searchView.setImeOptions(options| EditorInfo.IME_FLAG_NO_EXTRACT_UI);
searchView.setSearchableInfo( searchManager.getSearchableInfo(getComponentName()) );
searchView.setIconified(true);
searchView.clearFocus();
return true;
}
XML:
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_name"
android:searchSuggestAuthority="Search in a Collection/Book or Favorites"
/>
菜单
<item
android:id="@+id/search"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="ifRoom"
android:title="Search in a Collection/Book or Favorites"/>
答案 0 :(得分:1)
最后修好了。如果您使用android:imeOptions="actionSearch|flagNoExtractUi|flagNoFullscreen"
widget
,请将SearchView
放入SEARCHABLE xml中。
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_name"
android:imeOptions="actionSearch|flagNoExtractUi|flagNoFullscreen"
/>