Search code examples
androidandroid-camerasurfaceview

Android animated Camera Surfaceview


I got an Surface view with a camera attached to it. The view is in a modal and gets slided up on start of the modal. But only the surface view gets animated and not the image of the camera. Is there a way to fix this or is it simply impossible?


Solution

  • The SurfaceView has two parts, the Surface and the View. Generally the View is a transparent window that leaves a "hole" in the View layer, allowing you to see the Surface layer behind it. The Camera preview is sent to the Surface.

    I'm not entirely sure what you're describing, but it sounds like you're moving the View without moving the Surface behind it.

    You can fix that, but even if you do, you will still likely be disappointed, because the View layer and the Surface layer usually move at slightly different times, causing a weird shuddering effect. You can't smoothly move both parts of a SurfaceView.

    You would be better off using a TextureView (API 14+), which is actually part of the View layer.