How to use cameraX with SurfaceView/TextureView?

2.4k views Asked by At

I am planning to migrate camera api to camerax. Currently I am using SurfaceView to show the camera preview. I noticed that camerax is using PreviewView to show the camera preview. As this library is still in alpha stage, so what is the alternate for that?

I know that previewView internally using SurfaceView/TextureView.

How can I explicitly configure and use SurfaceView/TextureView?

1

There are 1 answers

1
Xi 张熹 On

Your best bet is using PreviewView. Managing the Surface correctly requires working around many corner cases. If you insist of writing your own code, please take a look at PreviewView's implementation and start from there.

See: SurfaceView implementation and TextureView implementation