2010-03-23 10 views
7

Eventuali duplicati:
Android OpenGL ES Transparent BackgroundAndroid, sub-GLSurface trasparente nel layout?

vorrei visualizzare un oggetto 3D in cima alla schermata normale layout dell'interfaccia utente 2D.

La schermata dell'interfaccia utente 2 ha l'immagine di sfondo e GLSurfaceView è figlio del layout del contenuto.

ho provato la stessa tecnica del Translucent GLSurfaceView nel campione ApiDemos,

ma GLSurfaceView cancella tutti e mostra sfondo nero.


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

Posso conservare l'immagine di sfondo sottostante in questa situazione?

risposta

25

questo risolto per me:

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

grazie, questo è quello che voglio. – efeyc

+2

@ P.Melch Questo rende GlSurfaceView in cima a tutte le visualizzazioni. Ora non riesco a impostare un'altra vista su GlSurfaceView. C'è un altro modo per rendere trasparente GlSurfaceView. –

+0

@ P.Melch Stesso problema Zorder-top rende l'altra vista dietro GLsurfaceview – ask4solutions

Problemi correlati