10

I am currently working on an Android App that needs several overlapping SurfaceViews in one screen.

To be precise, I have two active overlapping SurfaceViews, one connected to Camera and the other connected to MediaPlayer. It mostly works but is not stable. At times, one of the SurfaceViews does not show up.

I saw a thread from 2009(http://groups.google.com/group/android-developers/browse_thread/thread/08e7df2e96a7973d) that says overlapping SurfaceViews are not supported in Android. Is this still the case? Anyone can share experience on this?

Oak Bytes
  • 4,649
  • 4
  • 36
  • 53
Out Of Office
  • 427
  • 5
  • 13

3 Answers3

16

I found it out myself. Call setZOrderOnTop(true) on the SurfaceView I want to have on top seems solve the problem

Out Of Office
  • 427
  • 5
  • 13
2
surface.setZOrderOnTop(true);
surface.setZOrderMediaOverlay(true);

If two of Surfaceview are set, there will be a problem of occlusion, if you want one of them to be at the top, then only set Setzorderontop (true), but in doing so, it will always be at the top, and any other view will be blocked, if you set Setzorderontop and set Setzordermediaoverlay, that Setzorderontop will fail

Nathan Tuggy
  • 2,237
  • 27
  • 30
  • 38
马学忠
  • 21
  • 1
0

I had written an application once, with overlapping Linear Layouts. It worked fine when I overlapped them with view.layout(l,t,r,b). I am not sure if that also works with SurfaceViews. How do you overlap them?

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
Tom Dezentje
  • 631
  • 3
  • 16
  • Thanks for the fast response. I think surfaceview is a bit different from other regular views. I use framelayout to overlap them.<> – Out Of Office Oct 10 '11 at 14:31