surfaceview遮挡了上面的控件显示的解决方法

来源:互联网 发布:python编译器怎么用 编辑:程序博客网 时间:2024/06/02 12:48
最近在项目中使用到surfaceview做视频的实时流,遇到一个很奇葩的效果 ,在使用surfaceview因为surfaceview是双缓存机制,所以他需要设置
setZOrderOnTop(true);

让他显示在所依赖的窗口的最顶层才能更好的显示

这个是在surfaceview里面找到的源码。


遇到这样的情况的解决办法是在surfaceview调用

setZOrderOnTop(true)之后调用 setZOrderMediaOverlay(true)就可以了覆盖在surfaceview就会显示出来了 ,点击事件也同样的响应。


/** * 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;}
这是setZOrderMediaOverlay(true)的源码。


看这两个源码,看他注释应该就很容易懂了


1 0
原创粉丝点击