Android GLSurfaceView transparent background without setZOrderonTop

后端 未结 4 1663
轻奢々
轻奢々 2020-12-17 15:43

Sorry for my English.

My work is based on https://github.com/harism/android_page_curl/

After many hours of research, I have found a few solutions, but not fo

相关标签:
4条回答
  • 2020-12-17 15:57

    I would like to accomplish the same thing with a view on top of a GLSurfaceView and I have not found a solution without limitations. First, glView.setZOrderOnTop(true) gives the correct transparent background but the view is alway on top no matter what the sequence of ordering views. Second, without ZOrderOnTop the view hierarchy is maintained but the GLSurface background is black or the color that is set with glClearColor(red, green, blue, alpha) in the renderer. Unfortunately, the alpha argument has no effect when using this method unless

    android:windowIsTranslucent="true"
    

    and the problem with this is that you may not want to punch a hole into the OS view. There should be a way to accomplish this easily for a more animated UI using openGL. I have searched this site and others without finding a solution.

    0 讨论(0)
  • 2020-12-17 15:58

    I was also facing the same issue that nothing view was showing when I was using GLSurfaceView.

    After getting the reference of GLSurfaceView do like this

    glSurface=findViewById(R.id.gl_surfaceview)
    
    //this is the import line only
    
    glSurface.setZOrderOnTop(false)
    

    now my all view are visible on top of GLSurfaceView

    Thanks.

    0 讨论(0)
  • 2020-12-17 15:59

    This worked for me:

    final GLSurfaceView glView = (GLSurfaceView) findViewById(R.id.glView);
    
    glView.setZOrderOnTop(true);
    glView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    glView.getHolder().setFormat(PixelFormat.RGBA_8888);
    glView.setRenderer(new MyRenderer());
    glView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
    

    Found here: http://andrewhague.wordpress.com/2011/05/24/how-to-set-a-transparent-glsurfaceview/

    0 讨论(0)
  • 2020-12-17 15:59

    I'm working the same problem. I found that you have to make the calls for

    setZOrderOnTop(true);
    getHolder().setFormat(PixelFormat.RGBA_8888);
    

    before the call to

    setRenderer(...);
    

    Good luck!

    0 讨论(0)
提交回复
热议问题