I need a GLSurfaceView with a transparent background (because I need to see the view below), and I successfully created it with the following code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/test"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/test" />
<android.opengl.GLSurfaceView
android:id="@+id/surfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bar" />
<ImageView
android:id="@+id/view_test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:padding="10dp"
android:src="@drawable/ic_test" />
</RelativeLayout>
From what I understood, the only way to make GLSurfaceView transparent is to add view.setZOrderOnTop (true) to the GLSurfaceView file . Following is how I declared GLSurfaceView:
mGlSurfaceView.setZOrderOnTop(true); //this is the line of code that is causing my problem
mGlSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
mGlSurfaceView.setEGLContextClientVersion(2);
mGlSurfaceView.getHolder().setFormat(PixelFormat.RGBA_8888);
mGlSurfaceView.setRenderer(mRenderer);
mGlSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
mGlSurfaceView.requestRender();
Now that the ZOrderOnTop flag is set to true, I no longer see the ImageView, which is in xml after GLSurfaceView.
My question is: Is there a way to place a view over a transparent GLSurfaceView?
Danno source
share