ItemAnimator class provides mechanism for animating child views. It can be used to animate adding, removing, modifying and moving a child view. If you want custom animations you can subclass ItemAnimator. DefaultItemAnimator class provide animations for basic operations like adding, removing and changing items

  • Fade in and fade out (for adding and removing items)
  • Translate (for shifting remaining items to the right positions)
  • Cross-fade (for particular items updating)

To initiate these animations you have to notify the adapter how the data changed. For example, if an item was added to the adapter’s data at position 5, you would call notifyItemInserted(5).  The following snippet shows usage examples of these methods.

User newUser = new UsersData().getNewUser();

// Add item
adapter.addNewUser(position, newUser);
adapter.notifyItemInserted(position);

// Remove item
adapter.removeUser(position);
adapter.notifyItemRemoved(position);

// Change item
adapter.changeUser(position);
adapter.notifyItemChanged(position);