How to make the GLSurfaceView transparent

2019-03-01 05:52发布

问题:

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.

回答1:

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);


回答2:

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.