How do I animate the RecyclerView when the items appear for first time and also when the user scrolls, just like the way it works for the google plus app or the
Without any outside libraries in RecycleView.Adapter on method onBindViewHolder use animation like in example:
if (position>lastAnimatedPosition) {
//set init transitionY to animate from it
holder.itemView.setTranslationY(holder.itemView.getHeight());
//animate to orginal position
holder.itemView.animate().translationYBy(- holder.itemView.getHeight()).start();
lastAnimatedPosition=position;
}
Above code will animate from bottom every row in list. Animation will be done only once, but onBindViewHolder is running on scrolling so first scrolling of list will be with animation effect.
Very important is to initialise view to start of animation, so in example i set:
holder.itemView.setTranslationY( + Y change);
then animation go backs to orginal position:
holder.itemView.animate().translationYBy(- Y change).start();
If you need alpha do this that way:
holder.itemView.setAlpha(0);
holder.itemView.animate().apha(1).start();