Builder

class Builder : Builder<Preview!, PreviewConfig!, PreviewConfig.Builder!>, Builder<PreviewConfig.Builder!>, Builder<PreviewConfig.Builder!>, Builder<PreviewConfig.Builder!>
kotlin.Any
   ↳ androidx.camera.core.PreviewConfig.Builder

Builder for a PreviewConfig.

Summary

Public constructors

Creates a new Builder object.

Public methods

PreviewConfig!

Builds an immutable PreviewConfig from the current state.

static PreviewConfig.Builder!
fromConfig(configuration: PreviewConfig!)

Generates a Builder from another Config object

PreviewConfig.Builder!

Sets the default handler that will be used for callbacks.

PreviewConfig.Builder!

Sets the primary camera to be configured based on the direction the lens is facing.

PreviewConfig.Builder!

Sets the aspect ratio of the intended target for images from this configuration.

PreviewConfig.Builder!
setTargetName(targetName: String!)

Sets the name of the target object being configured.

PreviewConfig.Builder!
setTargetResolution(resolution: Size!)

Sets the resolution of the intended target from this configuration.

PreviewConfig.Builder!

Sets the rotation of the intended target for images from this configuration.

Public constructors

<init>

Builder()

Creates a new Builder object.

Public methods

build

fun build(): PreviewConfig!

Builds an immutable PreviewConfig from the current state.

Return
PreviewConfig!: A PreviewConfig populated with the current state.

fromConfig

static fun fromConfig(configuration: PreviewConfig!): PreviewConfig.Builder!

Generates a Builder from another Config object

Parameters
configuration PreviewConfig!: An immutable configuration to pre-populate this builder.
Return
PreviewConfig.Builder!: The new Builder.

setCallbackHandler

fun setCallbackHandler(handler: Handler!): PreviewConfig.Builder!

Sets the default handler that will be used for callbacks.

Parameters
handler Handler!: The handler which will be used to post callbacks.
Return
PreviewConfig.Builder!: the current Builder.

setLensFacing

fun setLensFacing(lensFacing: CameraX.LensFacing!): PreviewConfig.Builder!

Sets the primary camera to be configured based on the direction the lens is facing.

If multiple cameras exist with equivalent lens facing direction, the first ("primary") camera for that direction will be chosen.

Parameters
lensFacing CameraX.LensFacing!: The direction of the camera's lens.
Return
PreviewConfig.Builder!: the current Builder.

setTargetAspectRatio

fun setTargetAspectRatio(aspectRatio: Rational!): PreviewConfig.Builder!

Sets the aspect ratio of the intended target for images from this configuration.

This is the ratio of the target's width to the image's height, where the numerator of the provided Rational corresponds to the width, and the denominator corresponds to the height.

Parameters
aspectRatio Rational!: A Rational representing the ratio of the target's width and height.
Return
PreviewConfig.Builder!: The current Builder.

setTargetName

fun setTargetName(targetName: String!): PreviewConfig.Builder!

Sets the name of the target object being configured.

The name should be a value that can uniquely identify an instance of the object being configured.

Parameters
targetName String!: A unique string identifier for the instance of the class being configured.
Return
PreviewConfig.Builder!: the current Builder.

setTargetResolution

fun setTargetResolution(resolution: Size!): PreviewConfig.Builder!

Sets the resolution of the intended target from this configuration.

The target resolution attempts to establish a minimum bound for the preview resolution. The actual preview resolution will be the closest available resolution in size that is not smaller than the target resolution, as determined by the Camera implementation. However, if no resolution exists that is equal to or larger than the target resolution, the nearest available resolution smaller than the target resolution will be chosen.

Parameters
resolution Size!: The target resolution to choose from supported output sizes list.
Return
PreviewConfig.Builder!: The current Builder.

setTargetRotation

fun setTargetRotation(rotation: Int): PreviewConfig.Builder!

Sets the rotation of the intended target for images from this configuration.

This is one of four valid values: Surface#ROTATION_0, , Surface#ROTATION_180, Surface#ROTATION_270. Rotation values are relative to the "natural" rotation, Surface#ROTATION_0.

Parameters
rotation Int: The rotation of the intended target.
Return
PreviewConfig.Builder!: The current Builder.