简体   繁体   中英

SurfaceView overlaps another SurfaceView on Android 8.0

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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