يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-08-04 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-08-04 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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```"]]