Reputation: 31
I followed the guides on cameraX which all use PreviewView for displaying the camera output using
preview.setSurfaceProvider(PreviewView.createSurfaceProvider());
How do I set the preview to use a textureview instead of a PreviewView
Upvotes: 2
Views: 2101
Reputation: 41
You can specify which view to use in PreviewView between SurfaceView and TextureView. Before setting surfaceProvider, set the implementation mode
previewView.implementationMode = PreviewView.ImplementationMode.COMPATIBLE
Here previewView is the XML id of PreviewView. PreviewView.ImplementationMode.COMPATIBLE
is for TextureView. After setting this, the PreviewView will use TextureView to show Camera.
The implementation mode for SurfaceView is PreviewView.ImplementationMode.PERFORMANCE
This is compatible with
androidx.camera:camera-view:1.0.0-alpha22
Upvotes: 4