bumptech / bumptech/glide

Tinted drawable into ImageView only works with custom Target that does nothing

Open
#3,426 7 comments 0 reactions 0 assignees View on GitHub
bug reproducible
Dominant language
Java
Stars
35k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
8

Description

**Glide Version**:
4.8.0

**Device/Android Version**:
Pixel2@Android 9

**Issue details / Repro steps / Use case background**:
Trying to tint a drawable within my custom decoder.

Decoder snippet
```
OwnerInfoDecoder implements ResourceDecoder
//
AnimationDrawable animation = new AnimationDrawable();
animation.setOneShot(false);
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.ic_ghost_white_24dp);
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable.mutate(), ContextCompat.getColor(context, R.color.teal));
animation.addFrame(drawable, FRAME_DURATION);
return new AnimationDrawableResource(bitmapPool, animation);
```

Glide call:
```
GlideApp.with(getContext())
.load(item.getOwnerInfos())
.listener(new PlaceHolderRequestListener(ownerIcon))
.into(ownerIcon);
```

This doesn't work, no tint is applied.

Now I created a custom target which currently does NOTHING:

```
public class TintTarget extends ImageViewTarget {
public TintTarget(ImageView view) {
super(view);
}

public TintTarget(ImageView view, boolean waitForLayout) {
super(view, waitForLayout);
}

@Override
protected void setResource(@Nullable Drawable resource) {
view.setImageDrawable(resource);
}
}
```

and use `.into(new TintTarget(ownerIcon));` and now it works, without any other changes.

When I look at `DrawableImageViewTarget` which gets automatically created by Glide when just using `into(ImageView)`, then it doesn't work, even though my `TintTarget` is same thing?

What am I missing here?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.