2015-10-16 8 views
5

असल में मुझे कुछ चाहिए जैसे this (at the 30 second mark)मैं रीसाइक्लिंग व्यू के आइटम के प्रवेश द्वार को कैसे एनिमेट (स्लाइड) कर सकता हूं?

मैं चाहता हूं कि गतिविधि शुरू होने के बाद मेरे आइटम अनुक्रमिक रूप से स्लाइड करें।

मैंने गूगलिंग की कोशिश की। मुझे कुछ भी नहीं मिला जो मैं समझ सकता हूं। मैं अभी भी एंड्रॉइड के लिए विकासशील ऐप्स की इस पागल दुनिया के आसपास अपना रास्ता प्राप्त कर रहा हूं।

धन्यवाद।

+0

404 पृष्ठ की तरह recyclerView पर एनीमेशन जोड़े नहीं मिला .... अपने लिंक –

+0

@AmarbirSingh मैं अपने पद संपादित लेकिन उन्होंने अभी तक इसे मंजूरी नहीं दी है। वैसे भी यहां लिंक https://www.youtube.com/watch?v=Q8TXgCzxEnw#t=30 वह बात कर रहा था। –

+0

@Amarbir उस के लिए खेद है। मैंने पहले से ही लिंक संपादित किया है। –

उत्तर

3

आपको रीसाइक्लर व्यू एडाप्टर onBindViewHolder विधि के अंदर एनीमेशन चलाने की आवश्यकता है।

@Override 
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { 
    runEnterAnimation(viewHolder.itemView); 
} 

private void runEnterAnimation(View view) { 
     view.setTranslationY(Utils.getScreenHeight(context)); 
     view.animate() 
       .translationY(0) 
       .setInterpolator(new DecelerateInterpolator(3.f)) 
       .setDuration(700) 
       .start(); 
    } 
} 

अधिक जानकारी यहाँ http://frogermcs.github.io/Instagram-with-Material-Design-concept-is-getting-real/ (FeedAdapter पर नज़र)

+0

"प्रतीक उपयोग को हल नहीं कर सकता"। ऐसा क्यों है? –

+0

आपको स्क्रीन ऊंचाई के साथ setTranslationY प्रदान करने की आवश्यकता है। ऊंचाई प्राप्त करने के लिए यहां देखें http://stackoverflow.com/questions/1016896/get-screen-dimensions-in-pixels – HellCat2405

+0

बहुत अच्छा काम करता है। हालांकि एक और बात है। मैं अनुक्रमिक रूप से उन्हें कैसे एनिमेट कर सकता हूं? –

13

इस

recyclerView = (RecyclerView) findViewById(R.id.rv); 
     recyclerView.setHasFixedSize(true); 
     llm = new LinearLayoutManager(getApplicationContext()); 
     recyclerView.setLayoutManager(llm); 

     AnimationSet set = new AnimationSet(true); 

     Animation animation = new AlphaAnimation(0.0f, 1.0f); 
     animation.setDuration(500); 
     set.addAnimation(animation); 

     animation = new TranslateAnimation(
       Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, 
       Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f 
     ); 
     animation.setDuration(100); 
     set.addAnimation(animation); 

     controller = new LayoutAnimationController(set, 0.5f); 

     adapter = new RecycleViewAdapter(poetNameSetGets, this); 
     recyclerView.setLayoutAnimation(controller); 
+0

यह चयनित उत्तर होना चाहिए! –

+0

क्या आप जानते हैं कि जब मैं रीसाइक्लिंग व्यू से सभी डेटा साफ़ करता हूं तो मैं उस एनीमेशन का उपयोग कैसे कर सकता हूं? –

संबंधित मुद्दे