Reputation: 432
I've integrated chat in my project so I have a recycler view for messages. How can I insert each new item (from bottom) with animation? I've already tried to insert items with notifyItemRangeChanged()
and notifyItemInserted()
but the animation is not that smooth
Upvotes: 1
Views: 5780
Reputation: 167
Try this, it works for me In your adapter,
Animation animation = AnimationUtils.loadAnimation(context, R.anim.bottom_up); holder.itemView.startAnimation(animation);
Upvotes: 1
Reputation: 11477
The
DefaultItemAnimator
is responsible for a smooth transition when the adapter is notified !
So, Add the following when you initialize your recyclerview ...before notifyItemInserted(poisition)
recyclerView.setItemAnimator(new DefaultItemAnimator());
Upvotes: 0