'Kotlin - Setting background colour for transparent PNG in ImageView

I have an ImageView that has a drawable as its background.

This is how I attempted to do it:

imageView.background = drawable             
imageView.setColorFilter(Color.parseColor("#hexCode"))

The PNG is displayed, but the background colour isn't. What's the proper way to do it?

Expected output:

expected

Actual output:

actual



Solution 1:[1]

This is a work around Create another drawable and set the background color to the grey color

Create two imageviews with the same constraint and set the image resource of the first to the drawable and the second to the transparent imageview

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Abugewa Zenith