将透明 GLSurfaceview 覆盖到 Android 中的现有视图上?
您好,我一直在尝试将 GLSurfaceview 覆盖到现有视图上。下面的代码显示了我如何覆盖。唯一不起作用的是顶部 glsurfaceview 的透明度。
view = new GLSurfaceView(this);
view.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
view.getHolder().setFormat(PixelFormat.TRANSLUCENT);
view.setRenderer(new Level1Renderer(this));
setContentView(R.layout.test);
addContentView(view, new LayoutParams(100,400));
然后,我在渲染器中将背景颜色设置为
gl.glClearColor(0.0f, 0.0f, 0.0f, 0);
有人可以建议我遗漏什么吗?
Hi I have been trying to overlay a GLSurfaceview onto an existing view.The code below shows how I overlay. The only thing that doesnt work is the transparency of the glsurfaceview on top.
view = new GLSurfaceView(this);
view.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
view.getHolder().setFormat(PixelFormat.TRANSLUCENT);
view.setRenderer(new Level1Renderer(this));
setContentView(R.layout.test);
addContentView(view, new LayoutParams(100,400));
I have then set the background colour in my renderer as
gl.glClearColor(0.0f, 0.0f, 0.0f, 0);
Can someone advise me as to what I am leaving out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
代码是正确的,您可能需要添加
(以防您的视图被其他视图隐藏并且您需要将其放在顶部。)
the code is correct, you may want to add
(in case your view is hidden by other view and you need it on top.)
我也有这个问题。我试图通过补间覆盖 glSurfaceView (以及其他)的视图的 alpha 值来“淡出”整个屏幕。其他视图都褪色了,但 glSurfaceView 没有。
我发现 glSurfaceView 上的
setZOrderMediaOverlay(true)
...而不是setZOrderOnTop(true)
对我有用。I had an issue with this too. I was trying to 'fade' my whole screen out by tweening alpha values of a view overlaying glSurfaceView (plus others). Other views all faded, but not the glSurfaceView.
I found that
setZOrderMediaOverlay(true)
...rather thansetZOrderOnTop(true)
on the glSurfaceView worked for me.