संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
ऐनिमेशन वाली इमेज दिखाने के लिए, ड्रॉ की जा सकने वाली फ़ाइल को लोड करके, अपने ऐप्लिकेशन में ज़्यादा इंटरैक्टिव और दिलचस्प उपयोगकर्ता अनुभव बनाया जा सकता है. ऐनिमेशन वाली इमेज, लोडिंग इंडिकेटर, सफलता या गड़बड़ी के इंडिकेटर बनाने, गेम डेवलपमेंट में मदद करने, और यूज़र इंटरफ़ेस (यूआई) के अन्य फ़ंक्शन बनाने के लिए काम की होती हैं.
वर्शन के साथ काम करना
इसे लागू करने के लिए, ज़रूरी है कि आपके प्रोजेक्ट का minSDK एपीआई लेवल 21 या उससे ज़्यादा पर सेट हो.
डिपेंडेंसी
ऐनिमेशन वाली इमेज दिखाना
यहां दिया गया कोड, ऐनिमेशन वाला एक वेक्टर दिखाता है, जो दो स्थितियों के बीच अपने-आप टॉगल होता है:
यह वेक्टर संसाधन लोड करता है और समय के साथ ड्रॉइंग एट्रिब्यूट को ऐनिमेट करता है.
ऐसा Image इंस्टेंस जो ऐनिमेशन करने के लिए, Painter इंस्टेंस का इस्तेमाल करता है. यह ऐनिमेशन, rememberAnimatedVectorPainter() फ़ंक्शन की मदद से AnimatedImageVector और boolean स्टेटस से बनाया जाता है.
जब atEndtrue होता है, तो Painter इंस्टेंस ऐनिमेशन करना बंद कर देता है.
नतीजे
पहली इमेज. Compose में ऐनिमेशन वाला वेक्टर ड्रॉबल.
ऐसे संग्रह जिनमें यह गाइड शामिल है
यह गाइड, चुने गए क्विक गाइड के कलेक्शन का हिस्सा है. इसमें Android डेवलपमेंट के बड़े लक्ष्यों के बारे में बताया गया है:
इमेज दिखाएं
अपने Android ऐप्लिकेशन को शानदार लुक देने के लिए, चमकदार और दिलचस्प विज़ुअल इस्तेमाल करने की तकनीकें जानें.
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, Oracle और/या इससे जुड़ी हुई कंपनियों के ट्रेडमार्क या रजिस्टर किए हुए ट्रेडमार्क हैं.
आखिरी बार 2025-02-06 (UTC) को अपडेट किया गया.
[[["समझने में आसान है","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 (UTC) को अपडेट किया गया."],[],[],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)"]]