Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I animate (slide in) a RecyclerView's item's entrance?

Basically I want something like this (at the 30 second mark)

I want my items to slide in sequentially once the activity starts.

I tried Googling. I found nothing that I can understand. I'm still getting my way around this crazy world of developing apps for Android.

Thanks.

like image 889
Jeffrey Lopez Avatar asked Oct 16 '15 11:10

Jeffrey Lopez


1 Answers

Add animation on recyclerView like this

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);
like image 156
Mustanser Iqbal Avatar answered Sep 30 '22 18:09

Mustanser Iqbal