A
A
AlexTyl2018-07-11 12:21:03
Android
AlexTyl, 2018-07-11 12:21:03

How to set transparent background in SurfaceView?

Hello.
The application has a view with a graph, on top of which there is another view, a descendant of SurfaceView. The SurfaceView is supposed to be able to draw various objects so that they are on top of the graph.
The following methods are currently being called in the SurfaceView constructor:

setZOrderOnTop(true);
getHolder().setFormat(PixelFormat.TRANSPARENT);

The problem is that using the setZOrderOnTop method, any drawn object starts to be drawn on top of everything (for example, a drawn figure will be displayed not only on top of the chart, but also on top of the side menu, if called). If you do not use setZOrderOnTop or write setZOrderMediaOverlay instead, then this problem will not arise, however, the SurfaceView will have a solid black background instead of a transparent background.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question