CompositionSettings.Builder


class CompositionSettings.Builder


A builder for CompositionSettings instances.

Summary

Public constructors

Creates a new Builder.

Public functions

CompositionSettings

Builds the CompositionSettings.

CompositionSettings.Builder
setAlpha(alpha: @FloatRange(from = 0, to = 1) Float)

Sets the alpha.

CompositionSettings.Builder
setBorderColor(borderColor: @ColorInt Int)

Sets the border color.

CompositionSettings.Builder
setBorderWidthRatio(borderWidthRatio: @FloatRange(from = 0, to = 1) Float)

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

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

Sets the offset.

CompositionSettings.Builder
setRoundedCornerRatio(
    roundedCornerRatio: @FloatRange(from = 0, to = 1) Float
)

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

CompositionSettings.Builder
setScale(scaleX: Float, scaleY: Float)

Sets the scale.

CompositionSettings.Builder
setZOrder(zOrder: @IntRange(from = 0) Int)

Sets the z-order.

Public constructors

Builder

Added in 1.5.0
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 functions

setAlpha

Added in 1.5.0
fun setAlpha(alpha: @FloatRange(from = 0, to = 1) Float): CompositionSettings.Builder

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

Parameters
alpha: @FloatRange(from = 0, to = 1) Float

alpha value.

Returns
CompositionSettings.Builder

Builder instance.

setBorderColor

Added in 1.7.0-alpha02
fun setBorderColor(borderColor: @ColorInt Int): CompositionSettings.Builder

Sets the border color.

Parameters
borderColor: @ColorInt Int

border color value.

Returns
CompositionSettings.Builder

Builder instance.

setBorderWidthRatio

Added in 1.7.0-alpha02
fun setBorderWidthRatio(borderWidthRatio: @FloatRange(from = 0, to = 1) Float): CompositionSettings.Builder

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
borderWidthRatio: @FloatRange(from = 0, to = 1) Float

border width ratio value.

Returns
CompositionSettings.Builder

Builder instance.

setOffset

Added in 1.5.0
fun setOffset(
    offsetX: @FloatRange(from = "-1", to = 1) Float,
    offsetY: @FloatRange(from = "-1", to = 1) Float
): CompositionSettings.Builder

Sets the offset.

Parameters
offsetX: @FloatRange(from = "-1", to = 1) Float

offset X value.

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

offset Y value.

Returns
CompositionSettings.Builder

Builder instance.

setRoundedCornerRatio

Added in 1.7.0-alpha02
fun setRoundedCornerRatio(
    roundedCornerRatio: @FloatRange(from = 0, to = 1) Float
): CompositionSettings.Builder

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
roundedCornerRatio: @FloatRange(from = 0, to = 1) Float

rounded corner ratio value.

Returns
CompositionSettings.Builder

Builder instance.

setScale

Added in 1.5.0
fun setScale(scaleX: Float, scaleY: Float): CompositionSettings.Builder

Sets the scale.

Parameters
scaleX: Float

scale X value.

scaleY: Float

scale Y value.

Returns
CompositionSettings.Builder

Builder instance.

setZOrder

Added in 1.7.0-alpha02
fun setZOrder(zOrder: @IntRange(from = 0) Int): CompositionSettings.Builder

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

Parameters
zOrder: @IntRange(from = 0) Int

z-order value.

Returns
CompositionSettings.Builder

Builder instance.