7
可能重複:
Android OpenGL ES Transparent BackgroundAndroid,佈局中的透明子GLSurfaceView?
我想在普通2D UI佈局屏幕的頂部顯示一些3D對象。
2d UI屏幕具有背景圖像,GLSurfaceView是內容佈局的子節點。
我試過半透明GLSurfaceView的ApiDemos樣品中相同的技術,
但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);
...
我能保持在這種情況下底層的背景圖片?
感謝,這就是我想要的。 – efeyc 2012-01-06 12:24:02
@ P.Melch這使GlSurfaceView在所有視圖之上。現在我無法對GlSurfaceView設置另一個視圖。有沒有其他方法可以使GlSurfaceView透明。 – 2013-08-15 17:55:24
@ P.Melch相同的問題Zorder-top使其他視圖落後GLsurfaceview – ask4solutions 2014-10-08 10:47:12