Compiler gives me that setColorFilter is deprecated!
tab?.icon?.setColorFilter(
ContextCompat.getColor(requireActivity(), R.color.colorLogoGrey),
PorterDuff.Mode.SRC_IN
)
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))
Just use BlendModeColorFilterCompat, to avoid crash on old Android APIs.
BlendModeColorFilterCompat.createBlendModeColorFilterCompat(ContextCompat.getColor(yourContext, yourColor), BlendModeCompat.SRC_ATOP)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With