5

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.

zepolyerf
  • 1,098
  • 3
  • 16
  • 35

2 Answers2

18

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);
Mustanser Iqbal
  • 5,017
  • 4
  • 18
  • 36
6

You need to run animation inside the RecyclerView's Adapter onBindViewHolder method.

@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();
    }
}

More info here http://frogermcs.github.io/Instagram-with-Material-Design-concept-is-getting-real/ (look at the FeedAdapter)

HellCat2405
  • 752
  • 7
  • 16