Make a SurfaceView transparent without setZOrderOnTop(true)

I have a RelativeLayout containing a custom SurfaceView and other elements that must be drawn over the SurfaceView. I also need the SurfaceView to be transparent. I tried this answer: how to make surfaceview transparent. But with the setZOrderOnTop(true) the other elements over the SurfaceView in the RelativeLayout are shown above the Surface (and partially hidden if the surface have something paint).

How can I solve this problem? thanks


将持有者像素格式设置为RGBA_8888,

sv.setZOrderOnTop(true);    //very much necessary

getHolder().setFormat(PixelFormat.RGBA_8888);


I had success with the setZOrderMediaOverlay(true) instead of setZOrderOnTop(true) . It allows for both Views below and above the OpenGL SurfaceView.

Here it is in context:

GLSurfaceView glview = (GLSurfaceView)findViewById(R.id.surface);
glview.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
glview.getHolder().setFormat(PixelFormat.RGBA_8888);
glview.setZOrderMediaOverlay(true);
glview.setEGLContextClientVersion(2);
链接地址: http://www.djcxy.com/p/11450.html

上一篇: 如何模拟Windows RT

下一篇: 在没有setZOrderOnTop(true)的情况下使SurfaceView透明