0Pricing
Jetpack Compose Academy · Lektion

AnimatedVisibility und Crossfade

Animieren Sie das Erscheinen und den Wechsel von Inhalten.

AnimatedVisibility und Crossfade ist eine kostenlose Jetpack Compose Academy-Lektion auf CoddyKit. Dies ist Lektion 2 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Jetpack Compose Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Jetpack Compose Academy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

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. 🎉

Häufig gestellte Fragen

Ist die Lektion „AnimatedVisibility und Crossfade“ kostenlos?

Ja — der vollständige Text von „AnimatedVisibility und Crossfade“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Jetpack Compose Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Jetpack Compose Academy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „AnimatedVisibility und Crossfade“?

Animieren Sie das Erscheinen und den Wechsel von Inhalten. Du übst Jetpack Compose Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Jetpack Compose Academy zu starten?

Keine Vorkenntnisse erforderlich. Jetpack Compose Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 2 von 4.

Wie lange dauert die Lektion „AnimatedVisibility und Crossfade“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Jetpack Compose Academy-Lektion Code schreiben und ausführen?

Ja. Jede Jetpack Compose Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. animate*AsState für einfache Tweens
  2. AnimatedVisibility und Crossfade
  3. updateTransition für koordinierte Bewegungen
  4. Gestengesteuerte Animationen
← Zurück zu Jetpack Compose Academy