Google se compromete a impulsar la igualdad racial para las comunidades afrodescendientes. Obtén información al respecto.

CameraView

class CameraView : FrameLayout
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.FrameLayout
   ↳ androidx.camera.view.CameraView

A View that displays a preview of the camera with methods , takePicture(ImageCapture.OutputFileOptions, Executor, OnImageSavedCallback), startRecording(File, Executor, OnVideoSavedCallback callback) and stopRecording().

Because the Camera is a limited resource and consumes a high amount of power, CameraView must be opened/closed. CameraView will handle opening/closing automatically through use of a . Use bindToLifecycle(LifecycleOwner) to start the camera.

Summary

Nested classes

The capture mode used by CameraView.

Public constructors
<init>(@NonNull context: Context)

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?)

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?, defStyle: Int)

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int)

Public methods
Unit
bindToLifecycle(@NonNull lifecycleOwner: LifecycleOwner)

Binds control of the camera used by this view to the given lifecycle.

Unit

Turns on/off torch.

Int?

Returns the currently selected lensFacing.

CameraView.CaptureMode

Returns the scale type used to scale the preview.

Int

Gets the active flash strategy.

Float

Returns the maximum zoom ratio.

Float

Returns the minimum zoom ratio.

LiveData<PreviewView.StreamState!>

Gets the LiveData of the underlying PreviewView's PreviewView.StreamState.

PreviewView.ScaleType

Returns the scale type used to scale the preview.

Float

Returns the current zoom ratio.

Boolean

Queries whether the current device has a camera with the specified direction.

Boolean

Returns whether the view allows pinch-to-zoom.

Boolean

Boolean

Returns current torch status.

Boolean

Returns whether the bound camera supports zooming.

Boolean
onTouchEvent(@NonNull event: MotionEvent)

Boolean

Focus the position of the touch event, or focus the center of the preview for accessibility events

Unit
setCameraLensFacing(@Nullable lensFacing: Int?)

Sets the desired camera by specifying desired lensFacing.

Unit
setCaptureMode(@NonNull captureMode: CameraView.CaptureMode)

Sets the CameraView capture mode

Unit
setFlash(flashMode: Int)

Sets the active flash strategy.

Unit

Sets whether the view should allow pinch-to-zoom.

Unit
setScaleType(@NonNull scaleType: PreviewView.ScaleType)

Sets the view finder scale type.

Unit
setZoomRatio(zoomRatio: Float)

Sets the current zoom ratio.

Unit
startRecording(@NonNull file: File, @NonNull executor: Executor, @NonNull callback: OnVideoSavedCallback)

Takes a video