Is it possible to implement a picture on Android with a canvas?

I want to have a hole and not only a circle on the red layer, which is yellow. I tried this (and failed) with the following code in my onDraw() -Method:
canvas.drawBitmap(yellow, 0, 0, paint); canvas.drawBitmap(red, 0, 200, paint); Paint p = new Paint(); p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); canvas.drawCircle(300, 300, radius, p);
But when I use this code, it makes a hole through both bitmaps. In the end, this application should be a maze with a ball, holes and other things. When the ball hits the hole, it should appear under the red bit. Can this be realized?
Answer:
If someone should have the same problem: use View , not SurfaceView. This was my mistake because bg SurfaceView cannot be transparent.
android canvas paint ondraw
theyanu
source share