I\'m trying to implement a simple colorfilter on an imageview to turn the black image into a white image. In order to achieve that I do the following:
we
For Android 4.3 and 4.4, setColorFilter does not work. Use DrawableCompat instead.
val drawable = DrawableCompat.wrap(ContextCompat.getDrawable(
context,
R.drawable.b_clouded_rain));
DrawableCompat.setTint(drawable, foregroundColor);
DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN)
.setColorFilter(Color.BLACK, PorterDuff.Mode.MULTIPLY);
weatherImg.setImageResource(R.drawable.b_clouded_rain);