SurfaceView.setbackground () dominates my canvas

When I set the background to my surface view, I see what I set as the background. However, I cannot draw simple things like circles when I lock / unlock the canvas. All I see is a background image.

Is there something I am missing?

Any thoughts?

+3
source share
2 answers

The solution is very simple.

//get surface view and surface holder

mySurfaceView = (SurfaceView) findViewById(R.id.surfaceView);
surfaceHolder = mySurfaceView.getHolder();

//place surface view holder on top of the surface view
mySurfaceView.setZOrderOnTop(true);

//set pixels of the surface holder to transparent to see the color of the
//surface view background

surfaceHolder.setFormat(PixelFormat.TRANSPARENT);
0
source

Source: https://habr.com/ru/post/1760808/


All Articles