4

I have two surfaceviews in an app and one surfaceview needs to overlap the other surfaceview. For example, say there are two surfaceviews SurfaceView A and SurfaceView B. B needs to be on top of A which is accomplished by setting setZOrderOnTop(true) on B.

Now, I want to display some text or buttons on top of B but because it has Z order set as true the text or buttons added doesn't show on top but come underneath it. If the setZOrderOnTop property is not set then the text views and buttons does show up on top but then B doesn't overlap A.

I have tried placing SurfaceView B and the textview or buttons in FrameLayout but still it appears under B. Is there a way that z order can be set to true and still text or buttons can come on top of it?

thefrugaldev
  • 1,619
  • 4
  • 18
  • 36

1 Answers1

9

I was able to resolve the issue by using setZOrderMediaOverlay(true) instead of setZOrderOnTop.

The method setZOrderOnTop if set to true will always be on top of the window. So, in order to have overlay view over surface view setZOrderMediaOverlay should be used.

For more information, refer setZOrderMediaOverlay document here.

Piyush
  • 18,895
  • 5
  • 32
  • 63
thefrugaldev
  • 1,619
  • 4
  • 18
  • 36
  • @Piyush When will be using setZOrderOnTop method. I am a little bit confused about the difference between setZOrderMediaOverlayand setZOrderOnTop. I am not getting understand by documentation. – Shashank Gupta May 28 '19 at 05:14
  • @ShashankGupta setZOrderOnTop is on top ..no matters what you config.. the other one setZOrderMediaOverlay allows to have buttons above – Maher Abuthraa Oct 31 '19 at 08:52