Why is a SurfaceView in a Fragment still visible when the Fragment is hidden?

允我心安 提交于 2019-12-06 14:28:55

A SurfaceView creates an entirely separate graphics layer, composited by the system. The "hole" is included in the view hierarchy so the layout comes out right. There's a lot of things that don't quite work right when SurfaceView is involved.

A TextureView, by contrast, is actually part of the View itself, and will act appropriately. The disadvantage is that there's an extra step where pixels are copied from an off-screen buffer into the view. This is done by the GPU, so it's very fast, but if you're trying to animate a large portion of the screen at 60fps or minimize battery drain while playing a full-length movie then SurfaceView may be a better choice.

If using a TextureView is an option, doing so may make your life a bit simpler.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!