Interface used by Text composables to override text size to automatically grow or shrink text to fill the layout bounds.

Summary

Public companion functions

AutoSize
StepBased(minFontSize: TextUnit, maxFontSize: TextUnit, stepSize: TextUnit)

Automatically size the text with the biggest font size that fits the available space.

Cmn

Public companion functions

StepBased

fun StepBased(
    minFontSize: TextUnit = AutoSizeDefaults.MinFontSize,
    maxFontSize: TextUnit = AutoSizeDefaults.MaxFontSize,
    stepSize: TextUnit = 0.25.sp
): AutoSize

Automatically size the text with the biggest font size that fits the available space.

Parameters
minFontSize: TextUnit = AutoSizeDefaults.MinFontSize

The smallest potential font size of the text. Default = 12.sp. This must be smaller than maxFontSize; an IllegalArgumentException will be thrown otherwise.

maxFontSize: TextUnit = AutoSizeDefaults.MaxFontSize

The largest potential font size of the text. Default = 112.sp. This must be larger than minFontSize; an IllegalArgumentException will be thrown otherwise.

stepSize: TextUnit = 0.25.sp

The smallest difference between potential font sizes. Specifically, every font size, when subtracted by minFontSize, is divisible by stepSize. Default = 0.25.sp. This must not be less than 0.0001f.sp; an IllegalArgumentException will be thrown otherwise. If stepSize is greater than the difference between minFontSize and maxFontSize, minFontSize will be used for the layout.

Returns
AutoSize

AutoSize instance with the step-based configuration. Using this in a compatible composable will cause its text to be sized as above.