开始时,SeachView正常工作。在我切换到另一个片段之后,请返回然后单击搜索图标。工具栏已垂直扩展,如下图所示
代码段
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.main, menu);
// Associate searchable configuration with the SearchView
SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
searchView.setMaxWidth(Integer.MAX_VALUE);
// listening to search query text change
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
// filter recycler view when query submitted
adapter.getFilter().filter(query);
return false;
}
@Override
public boolean onQueryTextChange(String query) {
// filter recycler view when text is changed
stationAdapter.getFilter().filter(query);
return false;
}
});
super.onCreateOptionsMenu(menu, inflater);
}
答案 0 :(得分:0)
android:paddingStart="-16dp"
//根据需要设置dp
这对于后棒棒糖设备就足够了。