SurfaceView GLSurfaceView 叠加显示

其实目的是叠加视频和OpenGL ES的内容,视频在下层,OpenGL ES背景透明。

  • SurfaceView无需特别设置
  • GLSurfaceView设置:
setEGLContextClientVersion(2);

setEGLConfigChooser(8, 8, 8, 8, 16, 0);

setZOrderOnTop(true);

getHolder().setFormat(PixelFormat.TRANSLUCENT);

然后是setRenderer

  • 添加view关键代码
FrameLayout.LayoutParams p = new FrameLayout.LayoutParams(

                FrameLayout.LayoutParams.MATCH_PARENT,

                FrameLayout.LayoutParams.MATCH_PARENT);



GLSurfaceView vGL = new GLSurfaceView();

SurfaceView vSurface = new SurfaceView(this);

addContentView(vSurface, p);

addContentView(vGL, p);

 

 

你可能感兴趣的:(SurfaceView)