Inside Adapter class
1 2 3 4 5 6 7 8 9 10 11 |
/** * Here is the key method to apply the animation */ private void setAnimation(View viewToAnimate, int position) { // If the bound view wasn't previously displayed on screen, it's animated if (position > lastPosition) { Animation animation = AnimationUtils.loadAnimation(mainContext, android.R.anim.slide_in_left); viewToAnimate.startAnimation(animation); lastPosition = position; } } |
1 2 3 4 5 6 7 8 9 10 |
@Override public void onBindViewHolder(MyViewHolder holder, int position) { holder.cat_name.setText(categoryList.get(position).getName()); // Here you apply the animation when the view is bound // setAnimation(holder.container, position); } |
Where holder is main container (Relative Layout)