开发者

Overlay Transparent GLSurfaceview onto existing view in android?

开发者 https://www.devze.com 2023-02-22 16:25 出处:网络
Hi I have been trying to overlay a GLSurfaceview onto an existing view.The code below sh开发者_如何学Goows how I overlay. The only thing that doesnt work is the transparency of the glsurfaceview on to

Hi I have been trying to overlay a GLSurfaceview onto an existing view.The code below sh开发者_如何学Goows 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?


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消