CompositionSettings.Builder


public final class CompositionSettings.Builder


A builder for CompositionSettings instances.

Summary

Public constructors

Creates a new Builder.

Public methods

@NonNull CompositionSettings

Builds the CompositionSettings.

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

Sets the alpha.

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

Sets the border color.

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

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

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

Sets the offset.

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

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

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

Sets the scale.

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

Sets the z-order.

Public constructors

Builder

Added in 1.5.0
public Builder()

Creates a new 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 WHITE.

Public methods

setAlpha

Added in 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
@FloatRange(from = 0, to = 1) float alpha

alpha value.

Returns
@NonNull CompositionSettings.Builder

Builder instance.

setBorderColor

Added in 1.7.0-alpha02
public @NonNull CompositionSettings.Builder setBorderColor(@ColorInt int borderColor)

Sets the border color.

Parameters
@ColorInt int borderColor

border color value.

Returns
@NonNull CompositionSettings.Builder

Builder instance.

setBorderWidthRatio

Added in 1.7.0-alpha02
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 setRoundedCornerRatio.

Parameters
@FloatRange(from = 0, to = 1) float borderWidthRatio

border width ratio value.

Returns
@NonNull CompositionSettings.Builder

Builder instance.

setOffset

Added in 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
@FloatRange(from = "-1", to = 1) float offsetX

offset X value.

@FloatRange(from = "-1", to = 1) float offsetY

offset Y value.

Returns
@NonNull CompositionSettings.Builder

Builder instance.

setRoundedCornerRatio

Added in 1.7.0-alpha02
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
@FloatRange(from = 0, to = 1) float roundedCornerRatio

rounded corner ratio value.

Returns
@NonNull CompositionSettings.Builder

Builder instance.

setScale

Added in 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
@NonNull CompositionSettings.Builder

Builder instance.

setZOrder

Added in 1.7.0-alpha02
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
@IntRange(from = 0) int zOrder

z-order value.

Returns
@NonNull CompositionSettings.Builder

Builder instance.