Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Android bietet eine vorab geladene Animation, die ausgeführt wird, wenn du das Layout änderst. Legen Sie ein Attribut in der
, um das Android-System anzuweisen, diese Layoutänderungen zu animieren. Außerdem werden Standard-
Animationen erstellen.
<ph type="x-smartling-placeholder">
So sieht eine Standardlayoutanimation aus, wenn Sie einer Liste Elemente hinzufügen:
Abbildung 1: Layout animation.
Layout erstellen
Lege in der Layout-XML-Datei deiner Aktivität das Attribut android:animateLayoutChanges fest
auf true für das Layout, für das Sie Animationen aktivieren möchten:
Alle Inhalte und Codebeispiele auf dieser Seite unterliegen den Lizenzen wie im Abschnitt Inhaltslizenz beschrieben. Java und OpenJDK sind Marken oder eingetragene Marken von Oracle und/oder seinen Tochtergesellschaften.
Zuletzt aktualisiert: 2025-08-04 (UTC).
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-04 (UTC)."],[],[],null,["# Auto-animate layout updates\n\nAndroid offers preloaded animation that runs when you change the layout. Set an attribute in the\nlayout to tell the Android system to animate these layout changes, and it carries out system-default\nanimations for you.\n| **Tip** : If you want to supply custom layout animations, create a [LayoutTransition](/reference/android/animation/LayoutTransition) object and supply it to the layout with the [setLayoutTransition()](/reference/android/view/ViewGroup#setLayoutTransition(android.animation.LayoutTransition)) method.\n\nHere's what a default layout animation looks like when adding items to a list: \n**Figure 1.** Layout animation. \n\nCreate the layout\n-----------------\n\nIn your activity's layout XML file, set the `android:animateLayoutChanges` attribute\nto `true` for the layout that you want to enable animations for: \n\n```xml\n\u003cLinearLayout android:id=\"@+id/container\"\n android:animateLayoutChanges=\"true\"\n ...\n/\u003e\n```\n\nAdd, update, or remove items from the layout\n--------------------------------------------\n\nAdd, remove, or update items in the layout, and the items are animated automatically: \n\n### Kotlin\n\n```kotlin\nlateinit var containerView: ViewGroup\n...\nprivate fun addItem() {\n val newView: View = ...\n\n containerView.addView(newView, 0)\n}\n```\n\n### Java\n\n```java\nprivate ViewGroup containerView;\n...\nprivate void addItem() {\n View newView;\n ...\n containerView.addView(newView, 0);\n}\n```"]]