10

I have a RelativeLayout containing a custom SurfaceView and other elements that must be drawn over the SurfaceView. I also need the SurfaceView to be transparent. I tried this answer: how to make surfaceview transparent. But with the setZOrderOnTop(true) the other elements over the SurfaceView in the RelativeLayout are shown above the Surface (and partially hidden if the surface have something paint).

How can I solve this problem? thanks

Community
  • 1
  • 1
Addev
  • 31,819
  • 51
  • 183
  • 302

2 Answers2

3

Set the holder pixel format to RGBA_8888,

sv.setZOrderOnTop(true);    //very much necessary

getHolder().setFormat(PixelFormat.RGBA_8888);

ngesh
  • 13,398
  • 4
  • 44
  • 60
e7fendy
  • 176
  • 1
  • 5
0

I had success with the setZOrderMediaOverlay(true) instead of setZOrderOnTop(true). It allows for both Views below and above the OpenGL SurfaceView.

Here it is in context:

GLSurfaceView glview = (GLSurfaceView)findViewById(R.id.surface);
glview.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
glview.getHolder().setFormat(PixelFormat.RGBA_8888);
glview.setZOrderMediaOverlay(true);
glview.setEGLContextClientVersion(2);
Paul Wagener
  • 432
  • 6
  • 12
  • can you show me the piece of code for the same, i am using it as: setZOrderMediaOverlay(true); SurfaceHolder holder = getHolder(); holder.addCallback(this); holder.setFormat(PixelFormat.TRANSLUCENT); But it didn't show any thing,infact it goes beyond the other view. when activity is starting i can see that work i done on surface, but suddenly over come by my view. – skygeek May 07 '13 at 14:18
  • I added some context for that function call. It is in the onCreate of the activity that contains the surface. – Paul Wagener May 07 '13 at 17:31
  • thanx for the help, let me try it. – skygeek May 08 '13 at 07:38