简体   繁体   English

SurfaceView与Android 8.0上的另一个SurfaceView重叠

[英]SurfaceView overlaps another SurfaceView on Android 8.0

I'm facing some strange issue with my app on Android 8.0. 我在Android 8.0上的应用程序遇到了一些奇怪的问题。 I have my own scrollable widget, code is available on github . 我有自己的可滚动小部件,代码在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. 在屏幕上,国际象棋棋盘是一个SurfaceView,一个可滚动的移动儿童,棋子也是一个SurfaceView。 Another child of a scrollable view is simple LinearLayout. 可滚动视图的另一个子项是简单的LinearLayout。

The problem is when child SurfaceView is placed below the chess board, it is showed above it, while another child scrolls normally. 问题是当子SurfaceView放在棋盘下面时,它会显示在它上面,而另一个孩子正常滚动。 Look at the gif below. 看看下面的gif。

在此输入图像描述

The problem appeared on Android 8. On all previous versions it worked fine. 问题出现在Android 8上。在以前的所有版本中,它运行良好。

You can try this to make SurfaceView to top of the screen: 您可以尝试将SurfaceView设置为屏幕顶部:

surfaceView.setZOrderMediaOverlay(true);

The main tip is not to use setZOrderOnTop(true) , as it displays SurfaceView above any UI element. 主要提示不使用setZOrderOnTop(true) ,因为它在任何UI元素上方显示SurfaceView setZOrderMediaOverlay displays the SurfaceView below the UI, but above another SurfaceView. setZOrderMediaOverlay在UI下方显示SurfaceView,但在另一个SurfaceView上方。

More from here 更多来自这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM