Solution 1 :
As you can see from the documentation, setColorFilter(int color, PorterDuff.Mode mode)
is actually deprecated from API level 29.
Probably in your gradle file you have:
compileSdkVersion 29
By the way you can use setColorFilter
with an instance of BlendModeColorFilter
:
tab?.icon?.colorFilter(BlendModeColorFilter(R.color.colorAccent, BlendMode.SRC_IN))
Solution 2 :
Just use BlendModeColorFilterCompat, to avoid crash on old Android APIs.
BlendModeColorFilterCompat.createBlendModeColorFilterCompat(ContextCompat.getColor(yourContext, yourColor), BlendModeCompat.SRC_ATOP)
Problem :
Compiler gives me that setColorFilter is deprecated!
tab?.icon?.setColorFilter(
ContextCompat.getColor(requireActivity(), R.color.colorLogoGrey),
PorterDuff.Mode.SRC_IN
)
Comments
Comment posted by stackoverflow.com/questions/56716093/…
This will crash on lower API level, use MyDrawableCompat