How to change a bitmap’s opacity?

As far as I know, opacity or other color filters can’t be set on the Bitmap itself. You will need to set the alpha when you use the image:

If you’re using ImageView, there is ImageView.setAlpha().

If you’re using a Canvas, then you need to use Paint.setAlpha():

Paint paint = new Paint();
paint.setAlpha(100);
canvas.drawBitmap(bitmap, src, dst, paint);

Also, incorporating WarrenFaith’s answer, if you will use the Bitmap where a drawable is required, you can use BitmapDrawable.setAlpha().

Leave a Comment