Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Support for multiple active overlapping surface views in Android

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?

like image 204
Out Of Office Avatar asked Oct 10 '11 14:10

Out Of Office


2 Answers

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

like image 73
Out Of Office Avatar answered Oct 05 '22 11:10

Out Of Office


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

like image 24
马学忠 Avatar answered Oct 05 '22 12:10

马学忠