In my android application, I want to draw two images - img1 and img2. At first, I will draw img2 on Canvas
. After that i will draw img1 on Canvas
which will overlap img2. Img1 contains transparent part. The problem is that, transparent part of img1 is shown in Black color, but I want img2 to be visible through the transparent part of img1. I am not able to do that.
Please help me to solve this problem.
Thank you.
Code:
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Bitmap b = BitmapFactory.decodeResource(getResources(),
R.drawable.white_bg); //img2
canvas.drawBitmap(b, 0, 0, null);
canvas.save();
canvas.drawBitmap(realImage, 0, 0, null); //img1
}
Try bitmap.setHasAlpha(true)
after you load the bitmap.