Android,透明的sub-GLSurfaceView在布局?

可能重复:
Android OpenGL ES透明背景

我想在正常的二维UI布局屏幕上显示一些3D对象。

2D屏幕有背景图像,GLSurfaceView是内容布局的子节点。

我尝试了ApiDemos示例中半透明GLSurfaceView的相同技术,

但GLSurfaceView清除所有,并显示黑色的背景。


<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/my_background_image" > ... <android.opengl.GLSurfaceView android:id="@+id/glview" android:layout_width="fill_parent" android:layout_height="300px" android:windowIsTranslucent="true" (i'm not sure this is right) /> </LinearLayout> 

 setContentView(R.layout.main); ... glview = (GLSurfaceView) findViewById(R.id.glview); glview.setEGLConfigChooser(8, 8, 8, 8, 16, 0); glview.getHolder().setFormat(PixelFormat.TRANSLUCENT); glview.setRenderer(this); ... gl.glClearColor(0, 0, 0, 0); ... 

在这种情况下,我可以保留底层的背景图片吗?

Solutions Collecting From Web of "Android,透明的sub-GLSurfaceView在布局?"

这解决了它对我来说:

  glview = (GLSurfaceView)findViewById(R.id.glview); glview.setEGLConfigChooser(8,8,8,8,16,0); glview.setRenderer(new MyRenderer(this)); glview.getHolder().setFormat(PixelFormat.TRANSLUCENT); // this made it work for me - works only from sdk level 6 on, though.... glview.setZOrderOnTop(true);