Class

TextMotion

Implementation of possible TextMotion configurations on Android.

TextMotionSample

/**
 * This sample demonstrates how to define TextMotion on a Text composable that scales up and down
 * repeatedly.
 */
@Sampled
@Composable
fun TextMotionSample() {
    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),
    )
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: