GLSurfaceView set background transparent

The default background of GLSurfaceView is a black drop, even if it is called in onSurfaceCreated of Renderer

GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

 It will still be blacked first, no matter what color you are, if the content you need to load takes a certain amount of time, it will be blacked out first when adding GLSurfaceView to the form, which is a bad user experience, so it can make The solution for this View to not be black when it is added is to either optimize the content to be loaded so that the black time is very short, and the user cannot perceive it, or directly set transparency.

 

When GLSurfaceView is initialized, the transparent reference is set before setRenderer :

setEGLConfigChooser(8, 8, 8, 8, 16, 0);
getHolder().setFormat(PixelFormat.TRANSLUCENT);
setZOrderOnTop(true);
setRenderer(mRenderer); // set the renderer

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326279554&siteId=291194637