6

Hi I have been trying to overlay a GLSurfaceview onto an existing view.The code below shows how I overlay. The only thing that doesnt work is the transparency of the glsurfaceview 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 have then set the background colour in my renderer as

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

Can someone advise me as to what I am leaving out?

user1202136
  • 11,171
  • 4
  • 41
  • 62
user560571
  • 1,977
  • 3
  • 17
  • 17

2 Answers2

3

the code is correct, you may want to add

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

(in case your view is hidden by other view and you need it on top.)

ılǝ
  • 3,440
  • 2
  • 33
  • 47
1

I had an issue with this too. I was trying to 'fade' my whole screen out by tweening alpha values of a view overlaying glSurfaceView (plus others). Other views all faded, but not the glSurfaceView.

I found that setZOrderMediaOverlay(true)...rather than setZOrderOnTop(true) on the glSurfaceView worked for me.

Jon
  • 2,280
  • 2
  • 25
  • 33