Defines ways to render and place glyphs to provide readability and smooth animations for text.
TextMotionSample
/**
* This sample demonstrates how to define TextMotion on a Text composable that scales up and down
* repeatedly.
*/
@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),
)
}