Android的,透明的子GLSurfaceView的布局? [英] Android, Transparent sub-GLSurfaceView in layout?

查看:1161
本文介绍了Android的,透明的子GLSurfaceView的布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我想在普通2D UI布局屏幕上方显示一些3D对象。

I'd like to display some 3d object on top of the normal 2d ui layout screen.

二维UI屏幕有背景图像和GLSurfaceView是内容布局的孩子。

The 2d ui screen has background image, and GLSurfaceView is child of the content layout.

我试了半透明GLSurfaceView的ApiDemos样品相同的技术,

I tried the same technique of the Translucent GLSurfaceView in ApiDemos sample,

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

but GLSurfaceView clears all and shows black background.

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


我可以pserve底层背景图片$ P $在这种情况呢?


Can I preserve the underlying background image in this situation?

推荐答案

这解决了我:

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

这篇关于Android的,透明的子GLSurfaceView的布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆