Overlay a transparent GLSurfaceview on an existing view in android?

Hey. I am trying to overlay GLSurfaceview on an existing view. Below is the code as I impose. The only thing that doesn't work is the glsurfaceview transparency on top.

view = new GLSurfaceView(this); view.setEGLConfigChooser(8, 8, 8, 8, 16, 0); view.getHolder().setFormat(PixelFormat.TRANSLUCENT); view.setRenderer(new Level1Renderer(this)); setContentView(R.layout.test); addContentView(view, new LayoutParams(100,400)); 

I set the background color in my renderer as

  gl.glClearColor(0.0f, 0.0f, 0.0f, 0); 

Can someone advise me that I'm leaving?

+6
android transparency overlay glsurfaceview
source share
2 answers

the code is correct, you can add

 glView.setZOrderOnTop(true); glView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); 

(in case your view is hidden by a different view, and you need it from above).

+3
source share

I also had a problem with this. I tried to "fade out" the entire screen by changing the alpha values โ€‹โ€‹of the glSurfaceView being viewed (plus others). Other views have all disappeared, but not glSurfaceView.

I found that setZOrderMediaOverlay(true) ... and not setZOrderOnTop(true) on glSurfaceView worked for me.

+1
source share

All Articles