【让2D和3D完美结合】view上如何叠加 glSurfaceView? 本帖最后由 archer_xy 于 2012-04-28 16:19:18 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 view 上面叠加 glSurfaceView或者surfaceView 上面叠加 glSurfaceView懂的帮帮忙。 直接把这个glSurefaceView添加到viewgroup中拜,不过要设置一下surfaceview的属性, 透明, 而且要setZOrderTop(true), 位于最上层.... view和glSurefaceView都可以看成控件,然后在xml中用framelayout布局,这样可以不? 关键代码如下,screen是我的view类: if (screen == null) screen = new Screen(this); setContentView(R.layout.test_framelayout); frmLayout = (FrameLayout)findViewById(R.id.abc1); frmLayout.addView(screen);//一幅图 frmLayout2= (FrameLayout)findViewById(R.id.abc2); frmLayout2.addView(_glSurfaceView);//一个正方形这三行代码是为了正方形背景透明:_glSurfaceView.setEGLConfigChooser(8,8,8,8, 16, 0);_glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);scene.backgroundColor().setAll(0x00000000);xml代码如下<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <FrameLayout android:id="@+id/abc1" android:layout_height="wrap_content" android:layout_width="wrap_content" /> <FrameLayout android:id="@+id/abc2" android:layout_height="wrap_content" android:layout_width="wrap_content" /></FrameLayout> 通过测试,单独addView(screen),正常,显示了一幅图。单独addView(_glSurfaceView),也正常,一个正方形。但是,像代码中那样都加入,则只显示正方形,背景纯黑色。 为何同时addView(screen)和addView(_glSurfaceView)时,只能显示正方形呢? 搞定了,还要一句话:_glSurfaceView.setZOrderOnTop(true);感谢楼上几位,都有帮助,我把工程上传到了http://download.csdn.net/detail/archer_xy/4276249有兴趣的可以看看。 求android2.3下usb camera问题 求教安卓开的工具升级问题 VB写的服务端,android写的客户端,在模拟器上能通信,把android客户端按到手机上就不连接不上了 android获得Activity为Theme.Dialog Activity的值 生成Drawable问题 如何把bootanimation.zip 打包到android系统镜像? Android注册 求助!工程中没有android sdk! 我应该怎么选择?或者继续吗? 有人遇到过吗?adt-bundle-windows-x86问题 如何创建透明位图? Android手机通过与PC通讯的问题
或者
surfaceView 上面叠加 glSurfaceView懂的帮帮忙。
screen = new Screen(this);
setContentView(R.layout.test_framelayout);
frmLayout = (FrameLayout)findViewById(R.id.abc1);
frmLayout.addView(screen);//一幅图
frmLayout2= (FrameLayout)findViewById(R.id.abc2);
frmLayout2.addView(_glSurfaceView);//一个正方形
这三行代码是为了正方形背景透明:
_glSurfaceView.setEGLConfigChooser(8,8,8,8, 16, 0);
_glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
scene.backgroundColor().setAll(0x00000000);
xml代码如下<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" >
<FrameLayout android:id="@+id/abc1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<FrameLayout android:id="@+id/abc2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/></FrameLayout>
通过测试,单独addView(screen),正常,显示了一幅图。
单独addView(_glSurfaceView),也正常,一个正方形。但是,像代码中那样都加入,则只显示正方形,背景纯黑色。
感谢楼上几位,都有帮助,我把工程上传到了
http://download.csdn.net/detail/archer_xy/4276249
有兴趣的可以看看。