0Pricing
Jetpack Compose Academy · Aula

animate*AsState para Interpolações Simples

Anime automaticamente um único valor.

animate*AsState para Interpolações Simples é uma aula grátis de Jetpack Compose Academy no CoddyKit. Esta é a aula 1 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Jetpack Compose Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Jetpack Compose Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Animation, the Easy Way

Compose can animate changes for you. The simplest tool is the animate*AsState family, which smoothly moves a value from old to new. ✨

What animateDpAsState Does

When your target value changes, animateDpAsState returns a State that glides toward it over a few frames instead of jumping.

val size by animateDpAsState(targetValue = if (big) 200.dp else 100.dp)

Read It Like Normal State

The animated value is just a State you read with by. Use it in a Modifier and the UI follows the animation every frame.

Box(Modifier.size(size).background(Color.Blue))

A Whole Family of Helpers

There is one per type: animateFloatAsState, animateColorAsState, animateDpAsState, and more. Pick the one matching the value you want to tween.

Animate a Color

Use animateColorAsState to fade between colors. Toggle a boolean and watch the background shift smoothly from one tint to another. 🎨

val color by animateColorAsState(if (on) Color.Green else Color.Gray)

Animate Transparency

For fade in and out, animate a float and feed it to alpha. A value of 0f is invisible, 1f is fully opaque.

val a by animateFloatAsState(if (visible) 1f else 0f)
Box(Modifier.alpha(a))

Choose the Pace

Pass an animationSpec to control timing. A tween lets you set the duration in milliseconds and an easing curve.

animateDpAsState(target, animationSpec = tween(durationMillis = 500))

Spring for Bounce

Swap in a spring spec for natural, physics-based motion. Tune dampingRatio and stiffness to add a little playful bounce.

animateDpAsState(target, animationSpec = spring(dampingRatio = 0.4f))

It Reacts to State

You never call start or stop. When the target value changes during recomposition, the animation restarts toward the new goal automatically.

Smooth, Not Linear

Default easing makes motion feel alive by speeding up then slowing down. Easing curves like FastOutSlowInEasing avoid robotic, constant-speed movement.

Listen When It Finishes

Need to react when motion ends? Pass a finishedListener lambda, which fires once with the final value after the animation settles.

animateDpAsState(target) { final -> /* done */ }

Quick Check

Which spec gives motion a natural, bouncy physics feel?

Recap: One Value at a Time

You learned animate*AsState: change a target, read the animated State, and pick tween or spring. It is the quickest way to add smooth single-value motion. 🎉

Perguntas Frequentes

A aula “animate*AsState para Interpolações Simples” é grátis?

Sim — o texto completo de “animate*AsState para Interpolações Simples” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Jetpack Compose Academy, atualize para CoddyKit PRO. O curso de Jetpack Compose Academy inclui 4 aulas no total.

O que vou aprender em “animate*AsState para Interpolações Simples”?

Anime automaticamente um único valor. Você pratica Jetpack Compose Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Jetpack Compose Academy?

Nenhuma experiência prévia é necessária. Jetpack Compose Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 4.

Quanto tempo leva a aula “animate*AsState para Interpolações Simples”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Jetpack Compose Academy?

Sim. Cada aula de Jetpack Compose Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. animate*AsState para Interpolações Simples
  2. AnimatedVisibility e Crossfade
  3. updateTransition para Movimento Coordenado
  4. Animações Orientadas por Gestos
← Voltar para Jetpack Compose Academy