RandomPain73
RandomPain73

Reputation: 31

How do you use Textureview as a preview for cameraX [Java]

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

Answers (1)

Ashiqur Rahman Tahmid
Ashiqur Rahman Tahmid

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

Related Questions