[英]Add view on top of transparent SurfaceView?
This answer describes how to make a SurfaceView
with a transparent background. 此答案描述了如何使用透明背景制作
SurfaceView
。
However it requires setZOrderOnTop(true)
to be called on the SurfaceView
, which unsurprisingly puts the SurfaceView
on top of the other views. 但是它需要
setZOrderOnTop(true)
在被称为SurfaceView
,这勿庸置疑放SurfaceView
上的其他视图顶部。
This isn't exactly what I want. 这不是我想要的。 Given
View
s A
, C
, and SurfaceView
B
I would like to order the views as A
behind B
behind C
. 鉴于
View
小号A
, C
,并SurfaceView
B
我想订购的意见作为A
落后B
背后C
。
If B
weren't a SurfaceView
with a transparent background this would simply be: 如果
B
不是具有透明背景的SurfaceView
,那么这只是:
<RelativeLayout>
<ViewA>
<ViewB>
<ViewC>
</RelativeLayout>
Is it possible to achieve this when B
is a SurfaceView
with a transparent background? 当
B
是具有透明背景的SurfaceView
时,是否可以实现此目的?
There are four possible layers with the current SurfaceView API. 当前的SurfaceView API有四个可能的层。 From top to bottom:
从上到下:
The SurfaceView surface, and the surface with all of the Views, are composited by the system compositor. SurfaceView曲面和包含所有视图的曲面由系统合成器合成。 You cannot Z-order sandwich a SurfaceView surface between two Views.
你不能在两个视图之间将Z-order三明治夹在中间。 (If you want the full details, read this article . See also the multi-surface test activity in Grafika , which software-renders to three overlapping transparent SurfaceViews.)
(如果您需要完整的详细信息,请阅读本文 。另请参阅Grafika中的多表面测试活动,该软件将渲染为三个重叠的透明SurfaceView。)
What you may want to do is use a TextureView (API 14+), which has many of the same properties but interacts fully with Views. 您可能想要做的是使用TextureView (API 14+),它具有许多相同的属性,但与Views完全交互。 If you were using Canvas to draw on your SurfaceView, you may be able to use a custom View, which has the added advantage of hardware accelerated rendering.
如果您使用Canvas在SurfaceView上绘图,则可以使用自定义视图,该视图具有硬件加速渲染的附加优势。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.