I would like to make Canvas area transparent because I would like to add an Image behind it so that Canvas actions happen above the image.My code for the canvas is here
well, I am not sure about drawing the transparent canvas, but in your case you can do a tweak, that draw the canvas using the background image iteself.
And then you can draw/ paint by finger on it.
Code example:
BitmapDrawable bd = (BitmapDrawable)<YOUR_ACTIVITY>.this.getResources().getDrawable(R.drawable.<DRAWBLE_ID>);
Bitmap b = bd.getBitmap();
mBitmap = Bitmap.createBitmap(b,0,0,100,100); // This line is required only if you wanna some change in the bitmap you created
mCanvas = new Canvas(mBitmap);
In your onDraw()
method add this:
canvas.drawColor(0x00AAAAAA);
This will make your canvas
transparent and background View
will be visible.
You can create a Bitmap of the same size as the canvas. Erase all the colors of the bitmap using Color.TRANSPARENCY and set it as a canvas bitmap:
Bitmap transparentBitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(),
Bitmap.Config.ARGB_8888);
transparentBitmap.eraseColor(Color.TRANSPARENT);
canvas.setBitmap(transparentBitmap);