SearchView

简介

xxx

资料

SearchView使用详解
MaterialDesign之SearchView全面解锁

方法

SearchView

获焦

searchView.setFocusable(true);
searchView.requestFocusFromTouch();

搜图显于搜框否

searchView.setIconifiedByDefault(true);

搜框有内容显叉(无隐)

searchView.onActionViewExpanded();
searchView.setIconified(true);

搜框展开时显提按钮否

searchView.setSubmitButtonEnabled(true);

键盘回车键搜索

searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH);

提示

searchView.setQueryHint(getString(R.string.enterSearchKeyword));

去下划线

searchView.findViewById(R.id.search_plate).setBackground(null);
searchView.findViewById(R.id.submit_area).setBackground(null);
SearchView.SearchAutoComplete

搜框提示文本样式

searchAutoComplete.setHintTextColor(ContextCompat.getColor(this, R.color.gray));
searchAutoComplete.setTextColor(ContextCompat.getColor(this, R.color.background));
searchAutoComplete.setTextSize(13);

触发查询最少字符数(默2字符触发)

searchAutoComplete.setThreshold(1);

你可能感兴趣的:(android)