How to make the GLSurfaceView transparent

2019-03-01 05:38发布

I am drawing the object on GLSurfaceView using opengles. But GLSurfaceView is not the transparent. Instead of transparent its completely black in background.

Please help me how to make the GLSurfaceView transparent.

I used this code

setEGLConfigChooser(8, 8, 8, 8, 16, 0);
getHolder().setFormat(PixelFormat.TRANSLUCENT);

Thanks in advance.

2条回答
ゆ 、 Hurt°
2楼-- · 2019-03-01 05:55

What i do to get around this is I have regular view such as LinearLayouts within the xml and i call linearLayout.addView(glSurface); linearLayout2.addView(glSurface2);

After that i call them by the order i would like: linearLayout2.bringToFront(); linearLayout.bringToFront();

Let me know if you would like me to post code.

查看更多
混吃等死
3楼-- · 2019-03-01 06:05

You should add a another property for it:

getHolder().setFormat(PixelFormat.TRANSLUCENT);

// this made it work for me - works only from sdk level 6 on, though....

glview.setZOrderOnTop(true);
查看更多
登录 后发表回答