SurfaceView叠加展示
项目背景
最近集成网易云信的视频通讯SDK,碰到了一个问题。
画面展示用的是云信封装的SurfaceView,直接在布局中使用。结果绘制画面的时候总是出现覆盖问题。
PS:本地画面小窗展示(覆盖在远端界面之上),远端画面全屏展示。绘制远端画面的时候,本地小窗直接被覆盖。
解决方案
谷歌了一下“SurfaceView叠加”关键字。很多资料都提到了SurfaceView的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 {@link #setZOrderOnTop}.
大概翻译一下就是