How to place UI widgets on top of multiple Z ordered Surface Views in Android

喜夏-厌秋 提交于 2019-12-23 02:53:13

问题


I have 2 SurfaceViews and 1 button and they need to be arranged in a way similar to the attached screenshot. I was able to get SurfaceView B to be on top of SurfaceView A by calling surfaceViewB.setZOrderOnTop(true);

The problem is that, once I do that, SurfaceView B is placed above the actual Window and I'm no longer able to get the Button to be on top of it (eg. calling button.bringToFront() is useless here).

Any idea how this layout could be accomplished?


回答1:


You can use setZOrderMediaOverlay(boolean) to place SurfaceView B over SurfaceView A, but still behind the window. From documentation: Link:

public void setZOrderMediaOverlay (boolean isMediaOverlay)

Control whether the surface view's surface is placed on top of another regular surface view in the window (but still behind the window itself). This is typically used to place overlays on top of an underlying media surface view.

Note that this must be set before the surface view's containing window is attached to the window manager.

Calling this overrides any previous call to setZOrderOnTop(boolean).

So, the following should work for you:

surfaceViewB.setZOrderMediaOverlay(true);


来源:https://stackoverflow.com/questions/19727087/how-to-place-ui-widgets-on-top-of-multiple-z-ordered-surface-views-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!