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

TextStyleKt

public final class TextStyleKt


Summary

Public methods

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

Interpolate between two text styles.

static final @NonNull TextStyle
resolveDefaults(
    @NonNull TextStyle style,
    @NonNull LayoutDirection direction
)

Fills missing values in TextStyle with default values and resolve TextDirection.

Public methods

lerp

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

Interpolate between two text styles.

This will not work well if the styles don't set the same fields.

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.

resolveDefaults

public static final @NonNull TextStyle resolveDefaults(
    @NonNull TextStyle style,
    @NonNull LayoutDirection direction
)

Fills missing values in TextStyle with default values and resolve TextDirection.

This function will fill all null or TextUnit.Unspecified field with actual values.

Parameters
@NonNull TextStyle style

a text style to be resolved

@NonNull LayoutDirection direction

a layout direction to be used for resolving text layout direction algorithm

Returns
@NonNull TextStyle

resolved text style.