[英]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. 我有一个RelativeLayout包含一个自定义SurfaceView和其他必须在SurfaceView上绘制的元素。 I also need the SurfaceView to be transparent.
我还需要SurfaceView是透明的。 I tried this answer: how to make surfaceview transparent .
我试过这个答案: 如何使surfaceview透明 。 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).
但是使用setZOrderOnTop(true),RelativeLayout中SurfaceView上的其他元素显示在Surface上方(如果表面有油漆,则部分隐藏)。
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)
. 我使用
setZOrderMediaOverlay(true)
而不是setZOrderOnTop(true)
取得了成功。 It allows for both Views below and above the OpenGL SurfaceView. 它允许在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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.