'Toggles between red and green graphic images
I want an image that goes from green graphic to red graphic or red graphic to green graphic every time I click it. What do I need to do?
Solution 1:[1]
You can try to change the tint of ImageView as follow.
fun setImageTint(view: ImageView, color: Int) {
view.setColorFilter(ContextCompat.getColor(view.context, color), android.graphics.PorterDuff.Mode.SRC_ATOP)
}
Then you can toggle your imageview as follow for example.
setImageTint(yourImageView, toggle ? R.color.red : R.color.green)
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 | Min Thura |
