androidimageviewcolorfilter

Restore ImageView after setColorFilter


I'm trying to add DuoTone effect to my app by changing the Color of ImageView using setColorFilter, I have two buttons CANCEL and DONE.

CANCEL: If the user applies one of the effects and decides to cancel, I want to set the previous bitmap in ImageView

Code :

cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                originalImage = prevBitmap;
                fullImageView.setImageBitmap(originalImage);
                fullImageView.invalidate();
                hideViews();
            }
        });

MY PROBLEM: When I click on CANCEL button nothing happens, the ImageView does not change to the previous bitmap, the setColorFilter keeps applying, how I can restore/refresh/reset the ImageView


Solution

  • To remove color filter you've applied on image,

    You can call clearColorFilter() for the same image object

    For more info clearColorFilter