Compose में वेक्टर को ऐनिमेट करने के कई तरीके हैं. इनमें से किसी का भी इस्तेमाल किया जा सकता है:
AnimatedVectorDrawable
फ़ाइल फ़ॉर्मैट- Medium पर मौजूद इस लेख की तरह, Compose के ऐनिमेशन वाले एपीआई के साथ
ImageVector
- Lottie जैसा तीसरे पक्ष का समाधान
ऐनिमेटेड वेक्टर ड्रॉबल (प्रयोग के तौर पर उपलब्ध)
![रेत-घड़ी की सुविधा, अपने कॉन्टेंट को ऐनिमेट कर रही है और घुमा रही है](https://developer.android.com/static/develop/ui/compose/images/animations/avd_example_compose.gif?authuser=0&hl=hi)
AnimatedVectorDrawable
संसाधन का इस्तेमाल करने के लिए, animatedVectorResource
का इस्तेमाल करके ड्रॉ की जा सकने वाली फ़ाइल लोड करें. साथ ही, जिस ऐनिमेशन का इस्तेमाल किया जा सकता है उसकी शुरुआती और आखिरी स्थिति के बीच स्विच करने के लिए, boolean
पास करें.
@Composable fun AnimatedVectorDrawable() { val image = AnimatedImageVector.animatedVectorResource(R.drawable.ic_hourglass_animated) var atEnd by remember { mutableStateOf(false) } Image( painter = rememberAnimatedVectorPainter(image, atEnd), contentDescription = "Timer", modifier = Modifier.clickable { atEnd = !atEnd }, contentScale = ContentScale.Crop ) }
अपनी ड्रॉ करने लायक फ़ाइल के फ़ॉर्मैट के बारे में ज़्यादा जानकारी के लिए, ड्रॉ करने लायक ग्राफ़िक ऐनिमेट करें देखें.
आपके लिए सुझाव
- ध्यान दें: JavaScript बंद होने पर लिंक टेक्स्ट दिखता है
- इमेज लोड हो रही हैं {:#loading-images}