Search code examples
androidglsurfaceviewz-ordertextureviewcamera2

Camera2 preview is black, if I add a GLSurfaceView in front


I want to do an OpenGL animation (GLSurfaceView) in front of the Camera2 API preview (TextureView), but the animation isn't transparent. I've added the GLSurfaceView in front of the TextureView.

  • it only works, if I set the setZOrderOnTop(true); in the GLSurfaceView, but then all buttons and also the drawer is behind of the the view...

Is there a way to make the the GLSurfaceView (animation) transparent?


Solution

  • setZOrderOnTop() works, but it means that you cannot have anything above a transparent SurfaceView, which is unfortunate.

    The only way is, to replace the TextureView of the Camera2 preview, with a SurfaceView. Then I can use the setZOrderMediaOverlay(true); in the GLSurfaceView.

    setZOrderMediaOverlay(boolean isMediaOverlay)

    Control whether the surface view's surface is placed on top of another regular surface view in the window (but still behind the window itself).