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

后端 未结 8 2148
臣服心动
臣服心动 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:42

    You might use below lines of code:

    int searchMagIcon = getResources().getIdentifier("search_mag_icon", "id", "android");
    ImageView SearchHintIcon = (ImageView) searchView.findViewById(searchMagIcon);
    

    That will save the ImageView and then you can change it.

    0 讨论(0)
  • 2020-12-17 05:53

    Per the AppCompat v21 blog post, you can provide a custom style for your SearchView, overriding things such as the search icon:

    <style name="Theme.MyTheme" parent="Theme.AppCompat">
        <item name="searchViewStyle">@style/MySearchViewStyle</item>
    </style>
    <style name="MySearchViewStyle" parent="Widget.AppCompat.SearchView">
        <!-- Search button icon -->
        <item name="searchIcon">@drawable/custom_search_icon</item>
    </style>
    
    0 讨论(0)
提交回复
热议问题