# CompositionSettings.Builder

Artifact: [androidx.camera:camera-core](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/core/CompositionSettings.java+class:androidx.camera.core.CompositionSettings.Builder) Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/camera#1.5.0)

*** ** * ** ***


```
public final class CompositionSettings.Builder
```

<br />

*** ** * ** ***

A builder for `https://developer.android.com/reference/androidx/camera/core/CompositionSettings` instances.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder#Builder()()` Creates a new `https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder`. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/CompositionSettings` | `https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder#build()()` Builds the `https://developer.android.com/reference/androidx/camera/core/CompositionSettings`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder` | `https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder#setAlpha(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, to = 1) float alpha)` Sets the alpha. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder` | `https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder#setBorderColor(int)(@https://developer.android.com/reference/androidx/annotation/ColorInt int borderColor)` Sets the border color. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder` | `https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder#setBorderWidthRatio(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, to = 1) float borderWidthRatio)` Sets the border width as a normalized ratio from 0 to 1. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder` | `https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder#setOffset(float,float)( @https://developer.android.com/reference/androidx/annotation/FloatRange(from = "-1", to = 1) float offsetX, @https://developer.android.com/reference/androidx/annotation/FloatRange(from = "-1", to = 1) float offsetY )` Sets the offset. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder` | `https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder#setRoundedCornerRatio(float)( @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, to = 1) float roundedCornerRatio )` Sets the rounded corner ratio as a normalized value from 0 to 1. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder` | `https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder#setScale(float,float)(float scaleX, float scaleY)` Sets the scale. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder` | `https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder#setZOrder(int)(@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int zOrder)` Sets the z-order. |

## Public constructors

### Builder

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/camera#1.5.0)

```
public Builder()
```

Creates a new `https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder`.

The default alpha is 1.0f, the default offset is (0.0f, 0.0f), the default scale is (1.0f, 1.0f), the default rounded corner ratio is 0.0f, the default border width ratio is 0, and the default border color is `https://developer.android.com/reference/android/graphics/Color.html#WHITE`.

## Public methods

### build

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/camera#1.5.0)

```
public @NonNull CompositionSettings build()
```

Builds the `https://developer.android.com/reference/androidx/camera/core/CompositionSettings`.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/CompositionSettings` | `https://developer.android.com/reference/androidx/camera/core/CompositionSettings`. |

### setAlpha

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/camera#1.5.0)

```
public @NonNull CompositionSettings.Builder setAlpha(@FloatRange(from = 0, to = 1) float alpha)
```

Sets the alpha. 0 means fully transparent, 1 means fully opaque.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, to = 1) float alpha` | alpha value. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder` | Builder instance. |

### setBorderColor

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
public @NonNull CompositionSettings.Builder setBorderColor(@ColorInt int borderColor)
```

Sets the border color.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/ColorInt int borderColor` | border color value. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder` | Builder instance. |

### setBorderWidthRatio

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
public @NonNull CompositionSettings.Builder setBorderWidthRatio(@FloatRange(from = 0, to = 1) float borderWidthRatio)
```

Sets the border width as a normalized ratio from 0 to 1.

0 means no border. 1 means the border width equals half of the smaller dimension of the frame, which causes the borders to meet at the center and fill the smaller dimension. The ratio is relative to half of the smaller dimension of the frame, consistent with `https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder#setRoundedCornerRatio(float)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, to = 1) float borderWidthRatio` | border width ratio value. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder` | Builder instance. |

### setOffset

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/camera#1.5.0)

```
public @NonNull CompositionSettings.Builder setOffset(
    @FloatRange(from = "-1", to = 1) float offsetX,
    @FloatRange(from = "-1", to = 1) float offsetY
)
```

Sets the offset.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/FloatRange(from = "-1", to = 1) float offsetX` | offset X value. |
| `@https://developer.android.com/reference/androidx/annotation/FloatRange(from = "-1", to = 1) float offsetY` | offset Y value. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder` | Builder instance. |

### setRoundedCornerRatio

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
public @NonNull CompositionSettings.Builder setRoundedCornerRatio(
    @FloatRange(from = 0, to = 1) float roundedCornerRatio
)
```

Sets the rounded corner ratio as a normalized value from 0 to 1.

0 means no rounding (sharp corners). 1 means fully rounded (the radius of the rounded corners equals half of the smaller dimension of the frame, making the frame a circle if it's square, or pill-shaped if it's rectangular). Values in between provide partial rounding proportional to half of the smaller dimension of the frame.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, to = 1) float roundedCornerRatio` | rounded corner ratio value. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder` | Builder instance. |

### setScale

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/camera#1.5.0)

```
public @NonNull CompositionSettings.Builder setScale(float scaleX, float scaleY)
```

Sets the scale.

| Parameters |
|---|---|
| `float scaleX` | scale X value. |
| `float scaleY` | scale Y value. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder` | Builder instance. |

### setZOrder

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
public @NonNull CompositionSettings.Builder setZOrder(@IntRange(from = 0) int zOrder)
```

Sets the z-order. Larger z-order means rendered later (appears on top). Must be non-negative.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int zOrder` | z-order value. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/CompositionSettings.Builder` | Builder instance. |