GL表面和可见性:飘 [英] GL Surface and Visibility: Gone

查看:211
本文介绍了GL表面和可见性:飘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我在我的应用程序中的GLSurfaceView由GLSurfaceView.Renderer渲染和使用JPCt为库。

So I have a GLSurfaceView in my app being rendered by a GLSurfaceView.Renderer and using JPCt as library.

,表面是一种无形的RelativeLayout的(可见性:水涨船高)。当我改变的知名度,可见再回到水涨船高,布局显示和隐藏的预期,但GLSurfaceView不,它只是显示,不会隐藏,即使我可以点击的,现在项目后面吧。

The surface is in an invisible RelativeLayout (visibility: gone). When I change the visibility to "visible" then back to "gone", the layout shows and hides as expected, but the GLSurfaceView don't, it just shows and won't hide, even though I can click on items that are now "behind" it.

这似乎是一些图形缓冲区的问题,但我没有找到一个方法来得到这个工作...任何想法? 谢谢!

It seems like some graphical buffer issue, but I didn't find a way to get this to work... any ideas? Thanks!

推荐答案

SurfaceView (和 GLSurfaceView 推而广之)在Android的有趣的野兽。从Android的javadoc中引用:

SurfaceView (and GLSurfaceView by extension) are interesting beasts in Android. Citation from Android javadoc:

表面为Z排序,以便它是后面的窗口保持其   SurfaceView;在SurfaceView拳孔在其窗口允许其   要显示的表面。视图层次会照顾   正确的合成与表面的SurfaceView的兄弟姐妹   通常会出现在它的上面

The surface is Z ordered so that it is behind the window holding its SurfaceView; the SurfaceView punches a hole in its window to allow its surface to be displayed. The view hierarchy will take care of correctly compositing with the Surface any siblings of the SurfaceView that would normally appear on top of it

Android有一个内置的窗口合成器(窗口有一点不同的含义在这里)。你的状态栏是一个窗口,你的活动有一个窗口。但是,如果你的活动包含从表面上看,另一个窗口创建,仅仅是保持表面,而Android合成器绘制窗口,你可以欣赏到面的窗口。因此, SurfaceView 实际上只有一个透明区域。当你把它藏,面积不拉,没有反应到触摸,但表面窗口依然present,Android是不够聪明,隐藏窗口。

Android has a built-in window compositor (window has a bit different meaning here). Your status bar is a window, your activity has one window. But if your activity contains a surface view, another window is created, just to hold the surface, and android compositor draws the window with your views over the surface window. So the SurfaceView is really only a transparent area. When you hid it, the area is not drawn, does not react to touches, but the surface window is still present, android is not clever enough to hide the window.

我会建议两种解决方案

  • 请你表面透亮。然后,可以使空的表面,当你需要隐藏视图(<一href="http://stackoverflow.com/questions/2498494/android-transparent-sub-glsurfaceview-in-layout">Android,透明子GLSurfaceView布局?)
  • 完全删除从视图层次视图
  • 在另外一个有点哈克的方式是继承 GLSurfaceView 和呼叫 onDetachedFromWindow()能见度变为 GONE 。我没有测试过这一点,它可能无法正常工作。
  • Make your surface translucent. You can then render empty surface when you need to hide the view( Android, Transparent sub-GLSurfaceView in layout? )
  • Remove the view from view hierarchy altogether
  • Another a bit hacky way is to subclass GLSurfaceView and call onDetachedFromWindow() when visibility changes to GONE. I have not tested this and it might not work.

这篇关于GL表面和可见性:飘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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