question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Color attribute tint doesn't show when loading drawable

See original GitHub issue

Describe the bug Colour attributes (e.g. ?colorPrimary) applied as a tint to a drawable (see below example) are not shown in resulting BitmapDrawable when using imageView.load(R.drawable.tinted_icon)

e.g. tinted icon:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24.0"
    android:viewportHeight="24.0"
    android:tint="?colorPrimary"
    android:tintMode="src_in">
    <path
        android:fillColor="#00FF00"
        android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z" />
</vector>

Notice the android:fillColor="#00FF00", which is bright green, but the android:tint="?colorPrimary" with android:tintMode="src_in" which should result in overlaying colorPrimary completely.

What shows when using Coil’s load function: image

Expected behavior ImageView shows tinted drawable like so: image

To Reproduce Given a fresh app with a simple layout that contains two ImageViews, load the same drawable in two different ways like so:

val icon = findViewById<ImageView>(R.id.imageView)
val icon2 = findViewById<ImageView>(R.id.imageView2)
icon.load(R.drawable.tinted_icon)
icon2.setImageResource(R.drawable.tinted_icon)

Version Using coil version 0.11.0, Tested on:

  • Pixel2 XL API29
  • Nexus5 API24

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
colinrtwhitecommented, Aug 21, 2020

Fixed in 0.12.0.

2reactions
colinrtwhitecommented, Jul 27, 2020

Thanks for the report + taking a look into this. I believe this should be fixed as part of the next release which will be out later this week. You can also use the latest snapshot if you need the fix right away.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tinting ImageView not working on Android 5.0. Ideas how to ...
OS bug that's been fixed for a future release. ImageView's tint attribute was updated to use Drawable.setTint() rather than Drawable.
Read more >
Drawable | Android Developers
Other applications will not be able to load them. At a minimum, custom drawable classes ... Specifies tint color for this drawable as...
Read more >
Providing images for different appearances - Apple Developer
The view applies the tint color to every pixel that doesn't have an alpha of 0.0 , causing the image's shape to adopt...
Read more >
Using Color Correction effects in After Effects - Adobe Support
This change does not affect the other colors in your image. ... You can pick a color in your video and adjust the...
Read more >
painterResource() ignores ColorStateLists completely when ...
android:fillColor and android:strokeColor currently support color state lists but android:tint does not. Ideally they should both be supported ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found