2010-03-23 15 views
7

Duplicar posible:
Android OpenGL ES Transparent BackgroundAndroid, Transparente sub-GLSurfaceView en el diseño?

me gustaría mostrar un objeto 3D en la parte superior de la pantalla normal de diseño de interfaz de usuario 2d.

La pantalla 2d ui tiene una imagen de fondo, y GLSurfaceView es un elemento secundario del diseño del contenido.

Probé la misma técnica de la translúcido GLSurfaceView en la muestra ApiDemos,

pero GLSurfaceView borra todo y muestra fondo negro.


<?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); 
... 

¿Puedo preservar la imagen de fondo subyacente en esta situación?

Respuesta

25

esta resuelto para mí:

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); 
+0

gracias, eso es lo que quiero. – efeyc

+2

@ P.Melch Esto hace que GlSurfaceView esté en la parte superior de todas las vistas. Ahora no puedo establecer otra vista sobre GlSurfaceView. ¿Hay alguna otra manera de hacer que GlSurfaceView sea transparente? –

+0

@ P.Melch Mismo problema Zorder-top hace que la otra vista vaya detrás de GLsurfaceview – ask4solutions

Cuestiones relacionadas