I know there\'s already a lot of answers for this question here, and I wouldn\'t be creating another thread if I hadn\'t already tried everything I saw here. Anyway, the qu
Take the Drawable you want to tint, wrap it with a tinted drawable , and set it as a new one for the search menu item:
@JvmStatic
fun getTintedDrawable(inputDrawable: Drawable, @ColorInt color: Int): Drawable {
val wrapDrawable = DrawableCompat.wrap(inputDrawable.mutate())
DrawableCompat.setTint(wrapDrawable, color)
DrawableCompat.setTintMode(wrapDrawable, Mode.SRC_IN)
return wrapDrawable
}
Usage:
val drawable =getTintedDrawable(...)
searchMenuItem.icon = drawable
And this should work for all Android versions that android-x (support library) supports.