最近在项目中使用到surfaceview做视频的实时流,遇到一个很奇葩的效果 ,在使用surfaceview因为surfaceview是双缓存机制,所以他需要设置
复制代码
1setZOrderOnTop(true);
让他显示在所依赖的窗口的最顶层才能更好的显示
这个是在surfaceview里面找到的源码。
遇到这样的情况的解决办法是在surfaceview调用
setZOrderOnTop(true)之后调用 setZOrderMediaOverlay(true)就可以了覆盖在surfaceview就会显示出来了 ,点击事件也同样的响应。
复制代码
这是setZOrderMediaOverlay(true)的源码。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17/** * 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. * * <p>Note that this must be set before the surface view's containing * window is attached to the window manager. * * <p>Calling this overrides any previous call to {@link #setZOrderOnTop}. */ public void setZOrderMediaOverlay(boolean isMediaOverlay) { mWindowType = isMediaOverlay ? WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY : WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA; }
看这两个源码,看他注释应该就很容易懂了
最后
以上就是沉静溪流最近收集整理的关于surfaceview遮挡了上面的控件显示的解决方法的全部内容,更多相关surfaceview遮挡了上面内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复