Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – drawable.setColorFilter marked as deprecated

Posted on November 11, 2022 By

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

READ  [FIXED] How to solve Android license issue
Powered by Inline Related Posts
Android Tags:android, android-tablayout, android-viewpager, drawable, kotlin

Post navigation

Previous Post: [FIXED] android – how to change notification background color in nougat?
Next Post: [FIXED] android – How to make width ratio equal in XML GridView

Related Posts

[FIXED] android – By using Jetpack Navigation Compnent Android
[FIXED] android – java.text.ParseException: Unparseable date: “November 17, 2022 13:33” Android
[FIXED] Android Studio: How to get storage path from intent.Action_Open_Document_tree Android
[FIXED] android – How To Populate A Gridview With Images Retreieved From Firebase Storage Android
[FIXED] java – how do I set an Error message on spinner and button like on edittext without using toast message? Android
[FIXED] android – Is asking for camera, media or file permission considered collection of data? Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can VPN be traced by police?
  • Where were Kaiser-Frazer cars built?
  • How do you make gold rose gold paint?
  • What are the newest type of dentures?
  • Can you wear joggers as dress pants?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme