Add view on top of transparent SurfaceView?

This answer describes how to make the SurfaceView

background transparent.

However, calling setZOrderOnTop(true)

is required setZOrderOnTop(true)

, which unsurprisingly puts SurfaceView

on top of other views.

This is not exactly what I want. Taking into consideration View


, C

and SurfaceView


I would like to streamline the submission as an A

over B

for C


If B

you weren't SurfaceView

with a transparent background, it would be simple:



Can this be achieved when it B

is SurfaceView

with a transparent background?


source to share

1 answer

There are four possible layers with the current SurfaceView API. Top down:

  • setZOrderOnTop
  • (views)
  • setZOrderMediaOverlay
  • Default

Surface SurfaceView and surface with all Views are compiled by the system builder. You cannot sandwich a Z-order on a SurfaceView between two views. (If you'd like the full details, read this article . See also Multi-User Test Activity in Grafika , which software displays three overlapping transparent SurfaceViews.)

What you can do is use a TextureView (API 14+), which has many of the same properties, but fully interacts with views. If you've used Canvas to draw on a SurfaceView, you can use a custom view, which has the added benefit of being hardware accelerated .



All Articles