Android:表面视图
我有 SurfaceView 与 setZOrderOnTop(true)
。在绘图过程中透明 SurfaceView 的背景需要此标志。
如何在它前面显示任何视图?
I have SurfaceView with setZOrderOnTop(true)
.This flag is needed for the transparent SurfaceView's background during the drawing process.
How can I display any View in front of it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SurfaceView 的设计目的不是与其他视图合成。如 setZOrderOnTop 的文档中所述,一次设置此模式后,SurfaceView 顶部将看不到任何其他窗口内容。
如果你想进行合成,你必须自己在屏幕外进行合成,然后将结果绘制到 SurfaceView 中。
SurfaceViews are not designed to be composited with other views. As described in the doc for setZOrderOnTop, once you set this mode, none of the other window contents will be visible on top of the SurfaceView.
If you want to do compositing, you will have to do it yourself, off-screen, then draw the results into the SurfaceView.
根据我的经验,这仍然有效。
但如果你使用RelativeLayout,那就很难看了。
WallPaperService 使用 SurfaceView。
所以没有理由没有视图不能在SurfaceView的顶部......(我猜??)
In my experience, that still work.
But if you use a RelativeLayout, it will be ugly.
The WallPaperService are usung SurfaceView.
So there is no reason that no view can't be on the top of SurfaceView...(I guess??)