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

android, android-actionbar, android-appcompat, searchview

Solution

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();
}

Problem

How to remove or change the search view icon inside the edittext? I am using the Appcompat library. I used the below code to modify and remove but it's not working: ``` SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); View search_mag_icon = (View)searchView.findViewById(android.support.v7.appcompat.R.id.search_mag_icon); search_mag_icon.setBackgroundResource(R.drawable.ic_stub); //search_mag_icon.setVisibility(View.GONE); ```

Original source