When I use drawables from the AppCompat
library for my Toolbar
menu items the tinting works as expected. Like this:
-
This worked for me:
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
val inflater = menuInflater
inflater.inflate(R.menu.player_menu, menu)
//tinting menu item:
val typedArray = theme.obtainStyledAttributes(IntArray(1) { android.R.attr.textColorSecondary })
val textColor = typedArray.getColor(0, 0)
typedArray.recycle()
val item = menu?.findItem(R.id.action_chapters)
val icon = item?.icon
icon?.setColorFilter(textColor, PorterDuff.Mode.SRC_IN);
item?.icon = icon
return true
}
Or you can use tint in drawable xml: