1.修改SearchView样式
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 表示shape的四个角的角度。只适用于矩形shape,这里的角度是指圆角的程度 -->
<corners android:radius="17dp" />
<!-- 这个标签表示纯色填充,通过android:color即可指定shape中填充的颜色 -->
<solid android:color="#ffffff" />
</shape>
2.隐藏SearchView下划线
android:queryBackground="@null"
android:searchIcon="@null"
android:showDividers="none"
android:submitBackground="@null"
3.调用方式
mSearchView.onActionViewExpanded();
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
LogUtil.v("开始搜索onQueryTextSubmit");
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
网友评论