Search code examples
androidandroid-cameraandroid-animation

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


enter image description here

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?


Solution

  • 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.