Compose में, वेक्टर में ऐनिमेशन जोड़ने के लिए कुछ अलग-अलग तरीकों का इस्तेमाल किया जा सकता है. इनमें से कोई भी तरीका इस्तेमाल किया जा सकता है:
AnimatedVectorDrawableफ़ाइल फ़ॉर्मैटImageVectorCompose के ऐनिमेशन एपीआई के साथ, जैसे कि इस मीडियम लेख में बताया गया है- तीसरे पक्ष का कोई समाधान, जैसे कि Lottie
ऐनिमेटेड वेक्टर ड्रॉएबल (एक्सपेरिमेंटल)
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}