{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

TextUnitKt

public final class TextUnitKt


Summary

Public methods

static final @NonNull TextUnit
TextUnit(float value, @NonNull TextUnitType type)

Construct a new TextUnit.

static final @NonNull TextUnit
getEm(double receiver)

Creates an EM unit TextUnit

static final @NonNull TextUnit
getEm(float receiver)

Creates an EM unit TextUnit

static final @NonNull TextUnit
getEm(int receiver)

Creates an EM unit TextUnit

static final @NonNull TextUnit
getSp(double receiver)

Creates a SP unit TextUnit

static final @NonNull TextUnit
getSp(float receiver)

Creates a SP unit TextUnit

static final @NonNull TextUnit
getSp(int receiver)

Creates a SP unit TextUnit

static final boolean

false when this is TextUnit.Unspecified.

static final boolean

true when this is TextUnit.Unspecified.

static final @NonNull TextUnit
lerp(@NonNull TextUnit start, @NonNull TextUnit stop, float fraction)

Linearly interpolate between two TextUnits.

static final @NonNull TextUnit
takeOrElse(
    @NonNull TextUnit receiver,
    @NonNull Function0<@NonNull TextUnit> block
)

If this TextUnit then this is returned, otherwise block is executed and its result is returned.

static final @NonNull TextUnit
times(double receiver, @NonNull TextUnit other)

Multiply a TextUnit by a scalar.

static final @NonNull TextUnit
times(float receiver, @NonNull TextUnit other)

Multiply a TextUnit by a scalar.

static final @NonNull TextUnit
times(int receiver, @NonNull TextUnit other)

Multiply a TextUnit by a scalar.

Public methods

TextUnit

public static final @NonNull TextUnit TextUnit(float value, @NonNull TextUnitType type)

Construct a new TextUnit.

Parameters
float value

of the dimension

@NonNull TextUnitType type

dimension

getEm

public static final @NonNull TextUnit getEm(double receiver)

Creates an EM unit TextUnit

getEm

public static final @NonNull TextUnit getEm(float receiver)

Creates an EM unit TextUnit

getEm

public static final @NonNull TextUnit getEm(int receiver)

Creates an EM unit TextUnit

getSp

public static final @NonNull TextUnit getSp(double receiver)

Creates a SP unit TextUnit

getSp

public static final @NonNull TextUnit getSp(float receiver)

Creates a SP unit TextUnit

getSp

public static final @NonNull TextUnit getSp(int receiver)

Creates a SP unit TextUnit

isSpecified

public static final boolean isSpecified(@NonNull TextUnit receiver)

false when this is TextUnit.Unspecified.

isUnspecified

public static final boolean isUnspecified(@NonNull TextUnit receiver)

true when this is TextUnit.Unspecified.

lerp

public static final @NonNull TextUnit lerp(@NonNull TextUnit start, @NonNull TextUnit stop, float fraction)

Linearly interpolate between two TextUnits.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid.

Throws
kotlin.IllegalArgumentException

if start and stop have different TextUnitTypes, or either of the two has its TextUnitType equal to TextUnitType.Unspecified.

takeOrElse

public static final @NonNull TextUnit takeOrElse(
    @NonNull TextUnit receiver,
    @NonNull Function0<@NonNull TextUnit> block
)

If this TextUnit then this is returned, otherwise block is executed and its result is returned.

times

public static final @NonNull TextUnit times(double receiver, @NonNull TextUnit other)

Multiply a TextUnit by a scalar.

This operation works only if the right operand is not equal to TextUnit.Unspecified. The result of this operation is the same unit type of the given one.

times

public static final @NonNull TextUnit times(float receiver, @NonNull TextUnit other)

Multiply a TextUnit by a scalar.

This operation works only if the right operand is not equal to TextUnit.Unspecified. The result of this operation is the same unit type of the given one.

times

public static final @NonNull TextUnit times(int receiver, @NonNull TextUnit other)

Multiply a TextUnit by a scalar.

This operation works only if the right operand is not equal to TextUnit.Unspecified. The result of this operation is the same unit type of the given one.