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

TextMotion

@ExperimentalTextApi
public final class TextMotion


Defines ways to render and place glyphs to provide readability and smooth animations for text.

import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.material.LocalTextStyle
import androidx.compose.material.Text
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.TransformOrigin
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.text.style.TextMotion

val infiniteTransition = rememberInfiniteTransition()
val scale by infiniteTransition.animateFloat(
    initialValue = 1f,
    targetValue = 8f,
    animationSpec = infiniteRepeatable(tween(1000), RepeatMode.Reverse)
)

Text(
    text = "Hello",
    modifier = Modifier
        .graphicsLayer {
            scaleX = scale
            scaleY = scale
            transformOrigin = TransformOrigin.Center
        },
    // Text composable does not take TextMotion as a parameter.
    // Provide it via style argument but make sure that we are copying from current theme
    style = LocalTextStyle.current.copy(textMotion = TextMotion.Animated)
)

Summary

Nested types

public static class TextMotion.Companion

Public methods

boolean
equals(Object other)
int
@NonNull String

Public methods

equals

public boolean equals(Object other)

hashCode

public int hashCode()

toString

public @NonNull String toString()