TextMotion


Configures glyph rendering and placement for readability or smooth animations.

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.material3.LocalTextStyle
import androidx.compose.material3.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

Public companion properties

TextMotion

Renders text with maximum linearity to provide smooth scaling, translating, or rotating animations.

Cmn
android
TextMotion

Optimizes rendering for readability.

Cmn
android

Public functions

open operator Boolean
equals(other: Any?)
android
open Int
android
open String
android

Public companion properties

Animated

val AnimatedTextMotion

Renders text with maximum linearity to provide smooth scaling, translating, or rotating animations.

May slightly reduce readability on low-DPI devices.

Static

val StaticTextMotion

Optimizes rendering for readability.

Use for static (non-animated) text. This is the default.

Public functions

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

toString

open fun toString(): String