DefaultItemAnimator

public class DefaultItemAnimator
extends SimpleItemAnimator

java.lang.Object
   ↳ androidx.recyclerview.widget.RecyclerView.ItemAnimator
     ↳ androidx.recyclerview.widget.SimpleItemAnimator
       ↳ androidx.recyclerview.widget.DefaultItemAnimator


This implementation of RecyclerView.ItemAnimator provides basic animations on remove, add, and move events that happen to the items in a RecyclerView. RecyclerView uses a DefaultItemAnimator by default.

Summary

Inherited constants

Public constructors

DefaultItemAnimator()

Public methods

boolean animateAdd(RecyclerView.ViewHolder holder)

Called when an item is added to the RecyclerView.

boolean animateChange(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder, int fromLeft, int fromTop, int toLeft, int toTop)

Called when an item is changed in the RecyclerView, as indicated by a call to RecyclerView.Adapter.notifyItemChanged(int) or RecyclerView.Adapter.notifyItemRangeChanged(int, int).

boolean animateMove(RecyclerView.ViewHolder holder, int fromX, int fromY, int toX, int toY)

Called when an item is moved in the RecyclerView.

boolean animateRemove(RecyclerView.ViewHolder holder)

Called when an item is removed from the RecyclerView.

boolean canReuseUpdatedViewHolder(RecyclerView.ViewHolder viewHolder, List<Object> payloads)

When an item is changed, ItemAnimator can decide whether it wants to re-use the same ViewHolder for animations or RecyclerView should create a copy of the item and ItemAnimator will use both to run the animation (e.g.

If the payload list is not empty, DefaultItemAnimator returns true.

void endAnimation(RecyclerView.ViewHolder item)

Method called when an animation on a view should be ended immediately.

void endAnimations()

Method called when all item animations should be ended immediately.

boolean isRunning()

Method which returns whether there are any item animations currently running.

void runPendingAnimations()

Called when there are pending animations waiting to be started.

Inherited methods

Public constructors

DefaultItemAnimator

public DefaultItemAnimator ()

Public methods

animateAdd

public boolean animateAdd (RecyclerView.ViewHolder holder)

Called when an item is added to the RecyclerView. Implementors can choose whether and how to animate that change, but must always call dispatchAddFinished(RecyclerView.ViewHolder) when done, either immediately (if no animation will occur) or after the animation actually finishes. The return value indicates whether an animation has been set up and whether the ItemAnimator's RecyclerView.ItemAnimator.runPendingAnimations() method should be called at the next opportunity. This mechanism allows ItemAnimator to set up individual animations as separate calls to animateAdd(), animateMove(),