How to change SearchView elements' color?

后端 未结 9 1821
北海茫月
北海茫月 2020-12-31 02:47

I want to use SearchView in my project, but I have a problem with elements\' color. Let me show you: its fragmentDialog where I have my SearchView

I dont need to change

9条回答
  •  灰色年华
    2020-12-31 03:35

    This will help you if you want to change color of magnifying glass in Search view. if you use Material theme than this

     ImageView icon = album_search.findViewById(com.google.android.material.R.id.search_button);
            Drawable whiteIcon = icon.getDrawable();
            whiteIcon.setTint(Color.BLACK); //Whatever color you want it to be
            icon.setImageDrawable(whiteIcon);
    

    and if Appcompact theme than just change com.google.android.material.R.id.search_button to android.support.v7.appcompat.R.id.search_button

    Thats it

提交回复
热议问题