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

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

    I was digging about that a lot and finally I found this solution and it works for me!
    You can use this

    If you use appcompat try this:

    ImageView searchIconView = (ImageView) searchView.findViewById(android.support.v7.appcompat.R.id.search_button);
    searchIconView.setImageResource(R.drawable.yourIcon);
    

    If you use androidx try this:

    ImageView searchIconView = (ImageView) searchView.findViewById(androidx.appcompat.R.id.search_button);
        searchIconView.setImageResource(R.drawable.yourIcon);
    

    It will change the default serchview icon.

    Hope it helps!

提交回复
热议问题