SurfaceView与Android 8.0上的另一个SurfaceView重叠 [英] SurfaceView overlaps another SurfaceView on Android 8.0

查看:85
本文介绍了SurfaceView与Android 8.0上的另一个SurfaceView重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android 8.0上的应用遇到了一些奇怪的问题.我有自己的可滚动小部件,代码为

问题出现在Android 8上.在所有以前的版本中,它都可以正常工作.

解决方案

您可以尝试将 SurfaceView 制作到屏幕顶部:

  surfaceView.setZOrderMediaOverlay(true); 

主要技巧是不要使用 setZOrderOnTop(true),因为它会在任何UI元素上方显示 SurfaceView . setZOrderMediaOverlay 在用户界面下方但在另一个SurfaceView上方显示SurfaceView.

来自此处

I'm facing some strange issue with my app on Android 8.0. I have my own scrollable widget, code is available on github. It has two childs, which can be scrolled one by one indefinitely.

On the screen, the chess board is a SurfaceView and a scrollable moving child with chess pieces on it is also a SurfaceView. Another child of a scrollable view is simple LinearLayout.

The problem is when child SurfaceView is placed below the chess board, it is showed above it, while another child scrolls normally. Look at the gif below.

The problem appeared on Android 8. On all previous versions it worked fine.

解决方案

You can try this to make SurfaceView to top of the screen:

surfaceView.setZOrderMediaOverlay(true);

The main tip is not to use setZOrderOnTop(true), as it displays SurfaceView above any UI element. setZOrderMediaOverlay displays the SurfaceView below the UI, but above another SurfaceView.

More from here

这篇关于SurfaceView与Android 8.0上的另一个SurfaceView重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆