Color attribute tint doesn't show when loading drawable
See original GitHub issueDescribe 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:
Expected behavior ImageView shows tinted drawable like so:
To Reproduce
Given a fresh app with a simple layout that contains two ImageView
s, 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:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed in
0.12.0
.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.