简体   繁体   中英

Cannot perform animations of a view which is on top of a SurfaceView

在此处输入图像描述

Previously, I've been developed a library to facilitates the usage of Camera API: The Camerakit . I'm recently developing a new project with this library and I want to perform animations on the top of camera preview(which extends SurfaceView),I found when I added such as the following code to my application, the animations of the view is not performed properly with camera preview, but performed well when without camera preview.

// MainActivity.class
capture.animate().yBy(2000).setDuration(10000).start();

Is there a way to solve this problem?

I got this problem when i code android with Unity.Then I solved this problem by setting SurfaceView's level on the Z axis direction. As we all know,SurfaceView is a view which drew above the shell.Maybe you can got the SurfaceView's instance,then set it under the view.like this: ((SurfaceView)child).setZOrderOnTop(false); So,in fact,the animation has already run.It just be covered by SurfaceView.

Playing around with animating camera controls over a custom camera activity and I too ran into this problem. My camera controls would get cut off at an almost random point in their animation over the camera view. After playing around for a few hours as well as trying out Z ordering, the thing that worked for me was adding a full size child view with a background color (transparent works fine!). Not sure if the ordering of the view matters (I placed it right before/above the view I wanted to animate).

I finally figured it out. By changing the preview component which is SurfaceView to TextureView solve this issue. Now I can overlay any animation on my camera preview.

I also updated my code on Github .

This commit reproduces the issue. And this one solved it.

if you have to use surfaceview, there is a solution, put a no-TRANSPARENT view between surfaceview and your target view.

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