How to delete or change the searchview icon inside the SearchView actionBar?

后端 未结 8 2211
臣服心动
臣服心动 2020-12-17 04:57

\"screenshot\"

How to remove or change the search view icon inside the edittext? I am using the Appcompat libra

8条回答
  •  时光取名叫无心
    2020-12-17 05:32

    Finally found the solution. Try the following:

    try {
        Field mDrawable = SearchView.class.getDeclaredField("mSearchHintIcon");
        mDrawable.setAccessible(true);
        Drawable drawable =  (Drawable)mDrawable.get(your search view here);
        drawable.setAlpha(0);
    } catch (Exception e) {
        e.printStackTrace();
    }
    

提交回复
热议问题