0Pricing
Jetpack Compose Academy · Lección

AnimatedVisibility y Crossfade

Anime la aparición y los cambios de contenido.

AnimatedVisibility y Crossfade es una lección gratuita de Jetpack Compose Academy en CoddyKit. Esta es la lección 2 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Jetpack Compose Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Jetpack Compose Academy incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

Animating What Appears

Sometimes you want content to slide or fade in rather than pop. AnimatedVisibility animates a Composable as it enters and exits the screen. ✨

Wrap What You Show

Give AnimatedVisibility a boolean and a content lambda. When the boolean flips, it animates that content in or out for you.

AnimatedVisibility(visible = show) {
  Text("Hello!")
}

Default Enter and Exit

Out of the box it uses a gentle fade plus expand and shrink. The element appears and disappears smoothly without any extra configuration.

Customize the Entrance

Set the enter parameter to choose how content arrives. Combine transitions like fadeIn and slideInVertically with the plus operator.

enter = fadeIn() + slideInVertically()

Customize the Exit

The exit parameter controls how content leaves. You can mirror the entrance or pick a different effect like shrinkOut for variety.

exit = fadeOut() + shrinkVertically()

Slide, Expand, Scale

Compose ships many transitions: slideIn, expandHorizontally, scaleIn, and their exit pairs. Mix them to design exactly the motion you want.

Swapping Content Smoothly

To replace one Composable with another, reach for Crossfade. It fades the old content out while the new content fades in. 🔀

Crossfade on a Key

Give Crossfade a targetState. Whenever that value changes, it animates between the content produced for the old and new states.

Crossfade(targetState = screen) { current ->
  ScreenFor(current)
}

Great for Tabs and Screens

Crossfade shines when switching between distinct views, like loading versus loaded states or two tabs, giving a polished blend instead of a jarring swap.

Tune the Crossfade Timing

Pass an animationSpec to Crossfade to slow down or speed up the blend. A longer tween makes the transition feel softer and more deliberate.

Crossfade(state, animationSpec = tween(700)) { ... }

Pick the Right Tool

Use AnimatedVisibility to show or hide one thing, and Crossfade to swap between alternatives. Each solves a different appearance problem.

Quick Check

Which Composable smoothly swaps one piece of content for another?

Recap: Enter, Exit, Swap

You now animate appearance with AnimatedVisibility and blend between views with Crossfade, customizing enter, exit, and timing. 🎉

Preguntas frecuentes

¿La lección «AnimatedVisibility y Crossfade» es gratis?

Sí — el texto completo de «AnimatedVisibility y Crossfade» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Jetpack Compose Academy, actualiza a CoddyKit PRO. El curso de Jetpack Compose Academy incluye 4 lecciones en total.

¿Qué aprenderé en «AnimatedVisibility y Crossfade»?

Anime la aparición y los cambios de contenido. Practicas Jetpack Compose Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar Jetpack Compose Academy?

No se requiere experiencia previa. Jetpack Compose Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 2 de 4.

¿Cuánto tiempo toma la lección «AnimatedVisibility y Crossfade»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de Jetpack Compose Academy?

Sí. Cada lección de Jetpack Compose Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. animate*AsState para interpolaciones sencillas
  2. AnimatedVisibility y Crossfade
  3. updateTransition para movimiento coordinado
  4. Animaciones controladas por gestos
← Volver a Jetpack Compose Academy