با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
می توانید با بارگذاری یک فایل قابل ترسیم برای نمایش تصاویر متحرک، تجربه کاربری تعاملی و جذاب تری را در برنامه خود ایجاد کنید. تصاویر متحرک برای ایجاد نشانگرهای بارگیری، نشانگرهای موفقیت یا خطا، تسهیل توسعه بازی و سایر عملکردهای رابط کاربری مفید هستند.
سازگاری نسخه
این پیاده سازی مستلزم آن است که minSDK پروژه شما روی سطح API 21 یا بالاتر تنظیم شود.
وابستگی ها
نمایش یک تصویر متحرک
کد زیر یک بردار متحرک را نشان می دهد که به طور خودکار بین دو حالت جابجا می شود:
یک منبع برداری را بارگذاری می کند و ویژگی های طراحی را در طول زمان متحرک می کند.
یک نمونه Image که از یک نمونه Painter برای اجرای انیمیشن استفاده می کند که از حالت AnimatedImageVector و حالت boolean توسط تابع rememberAnimatedVectorPainter() ایجاد شده است.
وقتی atEndtrue باشد، نمونه Painter متحرک سازی را متوقف می کند.
نتایج
شکل 1. بردار متحرک قابل ترسیم در Compose.
مجموعه هایی که حاوی این راهنما هستند
این راهنما بخشی از مجموعههای راهنمای Quick Guide است که اهداف توسعه Android گستردهتری را پوشش میدهد:
نمایش تصاویر
تکنیک هایی را برای استفاده از تصاویر روشن و جذاب کشف کنید تا به برنامه اندروید خود ظاهر و احساس زیبایی ببخشید.
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-02-06 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-02-06 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Display an animated image\n\n\u003cbr /\u003e\n\nYou can create a more interactive and engaging user experience in your app by\nloading a drawable file to display animated images. Animated images are useful\nfor creating loading indicators, success or error indicators, facilitating game\ndevelopment, and various other UI functions.\n\nVersion compatibility\n---------------------\n\nThis implementation requires that your project minSDK be set to API level 21 or\nhigher.\n\n### Dependencies\n\n### Kotlin\n\n\u003cbr /\u003e\n\n```kotlin\n implementation(platform(\"androidx.compose:compose-bom:2025.08.00\"))\n implementation(\"androidx.compose.animation:animation.graphics.android:1.6.3\")\n \n```\n\n\u003cbr /\u003e\n\n### Groovy\n\n\u003cbr /\u003e\n\n```groovy\n implementation platform('androidx.compose:compose-bom:2025.08.00')\n implementation 'androidx.compose.animation:animation.graphics.android:1.6.3'\n \n```\n\n\u003cbr /\u003e\n\nDisplay an animated image\n-------------------------\n\nThe following code displays an animated vector that automatically toggles\nbetween two states:\n\n\n```kotlin\n@Composable\nfun AnimatedVectorDrawable() {\n val image = AnimatedImageVector.animatedVectorResource(R.drawable.ic_hourglass_animated)\n var atEnd by remember { mutableStateOf(false) }\n Image(\n painter = rememberAnimatedVectorPainter(image, atEnd),\n contentDescription = \"Timer\",\n modifier = Modifier.clickable {\n atEnd = !atEnd\n },\n contentScale = ContentScale.Crop\n )\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/compose/snippets/src/main/java/com/example/compose/snippets/animations/AnimationSnippets.kt#L915-L927\n```\n\n\u003cbr /\u003e\n\n### Key points about the code\n\n- Loads a vector resource, animating the drawing attributes over time.\n- An `Image` instance that uses a [`Painter`](/reference/kotlin/androidx/compose/ui/graphics/painter/Painter) instance to perform the animation, created from the `AnimatedImageVector` and `boolean` state by the `rememberAnimatedVectorPainter()` function.\n- When `atEnd` is `true`, the `Painter` instance stops animating.\n\nResults\n-------\n\n**Figure 1.** Animated vector drawable in Compose.\n\nCollections that contain this guide\n-----------------------------------\n\nThis guide is part of these curated Quick Guide collections that cover\nbroader Android development goals: \n\n### Display images\n\nDiscover techniques for using bright, engaging visuals to give your Android app a beautiful look and feel. \n[Quick guide collection](/develop/ui/compose/quick-guides/collections/display-images) \n\nHave questions or feedback\n--------------------------\n\nGo to our frequently asked questions page and learn about quick guides or reach out and let us know your thoughts. \n[Go to FAQ](/quick-guides/faq) [Leave feedback](https://issuetracker.google.com/issues/new?component=1573691&template=1993320)"]]