androidimageviewcolorfilter

setColorFilter not working


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:

    weatherImg.setColorFilter(Color.BLACK, PorterDuff.Mode.MULTIPLY);
    weatherImg.setImageResource(R.drawable.b_clouded_rain);

I've also tried to change to color in the color filter to red and white but all of them have no effect, what am I doing wrong?


Solution

  • As much as I hate to answer my own questions I found the problem: I should've used:

       weatherImg.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);