4

I would like to set iconTint for the menu item as you see below but I have a warning "Attribute iconTint is only used in API level 26 and higher" So is there another way to set tint of menu item icon.

Thanks!

<item
        android:id="@+id/navigation_schedule"
        android:icon="@drawable/ic_filter_list_black_24dp"
        android:iconTint="@color/black"
        android:title="@string/filter"
        app:showAsAction="always" />
Khaled Qasem
  • 879
  • 7
  • 20

1 Answers1

7

Okay, I've already found a solution.

By handling it with DrawableCompat :

 menu?.getItem(0)?.icon?.let {
            DrawableCompat.setTint(
                it,
                ContextCompat.getColor(this, R.color.black)
            )
        }
Khaled Qasem
  • 879
  • 7
  • 20