使用这样的代码
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchView filterPartsSearchView = (SearchView) searchItem.getActionView();
if (searchManager != null) {
filterPartsSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
}
filterPartsSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
filterPartsSearchView.setBackgroundColor(ResourcesCompat.getColor(getResources(), android.R.color.transparent, null));
View searchPlate = filterPartsSearchView.findViewById(androidx.appcompat.R.id.search_plate);
if (searchPlate != null) {
searchPlate.setBackgroundColor(Color.TRANSPARENT);
}
这是所选文本的参考图像
按下光标并按住突出显示文本时的第二张图像参考,同时在文本周围移动光标