如何从searchview中的edittext中删除关闭图标 [英] how to remove close icon from edittext in searchview
本文介绍了如何从searchview中的edittext中删除关闭图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试自定义搜索视图.我想摆脱搜索视图中的关闭图标.到目前为止我做了什么?
I am trying to customize the searchview. i wanted to get rid of close icon in searchview. what i have done so far?
int closeId =android.support.v7.appcompat.R.id.search_close_btn;
ImageView close = (ImageView)mSearchView.findViewById(closeId);
close.setVisibility(View.GONE);
此代码删除关闭图标.但是一旦我开始输入 editText 它就会重新出现.如何永久摆脱它?
this code removes the close icon. But as soon as i start typing in editText it appears back in. How to permanently get rid of it?
展开searchView时关闭图标被移除
close icon is remove when expanded searchView
当我输入editText时它又回来了.
it comes back in when i type in editText.
推荐答案
将此属性添加到您的 SearchView xml 布局文件:
Add this attribute to your SearchView xml layout file :
app:closeIcon="@android:color/transparent"
然后禁用关闭按钮:
ImageView btnClose = searchView.findViewById(R.id.search_close_btn);
btnClose.setEnabled(false);
这篇关于如何从searchview中的edittext中删除关闭图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文