ItemAnimator
This class defines the animations that take place on items as changes are made to the adapter. Subclasses of ItemAnimator can be used to implement custom animations for actions on ViewHolder items. The RecyclerView will manage retaining these items while they are being animated, but implementors must call dispatchAnimationFinished when a ViewHolder's animation is finished. In other words, there must be a matching dispatchAnimationFinished call for each animateAppearance(), animateChange()animatePersistence(), and animateDisappearance() call.
By default, RecyclerView uses DefaultItemAnimator.
See also
Inheritors
Types
Link copied to clipboard
The set of flags that might be passed to recordPreLayoutInformation.
Link copied to clipboard
interface ItemAnimatorFinishedListener
This interface is used to inform listeners when all pending or running animations in an ItemAnimator are finished.
Link copied to clipboard
A simple data structure that holds information about an item's bounds.
Properties
Link copied to clipboard
This ViewHolder was not laid out but has been added to the layout in pre-layout state by the LayoutManager.
Link copied to clipboard
The Item represented by this ViewHolder is updated.
Link copied to clipboard
Adapter notifyDataSetChanged has been called and the content represented by this ViewHolder is invalid.
Link copied to clipboard
The position of the Item represented by this ViewHolder has been changed.
Link copied to clipboard
The Item represented by this ViewHolder is removed from the adapter.
Functions
Link copied to clipboard
abstract fun animateAppearance(@NonNull viewHolder: RecyclerView.ViewHolder, @Nullable preLayoutInfo: RecyclerView.ItemAnimator.ItemHolderInfo, @NonNull postLayoutInfo: RecyclerView.ItemAnimator.ItemHolderInfo): Boolean
Called by the RecyclerView when a ViewHolder is added to the layout.
Link copied to clipboard
abstract fun animateChange(@NonNull oldHolder: RecyclerView.ViewHolder, @NonNull newHolder: RecyclerView.ViewHolder, @NonNull preLayoutInfo: RecyclerView.ItemAnimator.ItemHolderInfo, @NonNull postLayoutInfo: RecyclerView.ItemAnimator.ItemHolderInfo): Boolean
Called by the RecyclerView when an adapter item is present both before and after the layout and RecyclerView has received a notifyItemChanged call for it.
Link copied to clipboard
abstract fun animateDisappearance(@NonNull viewHolder: RecyclerView.ViewHolder, @NonNull preLayoutInfo: RecyclerView.ItemAnimator.ItemHolderInfo, @Nullable postLayoutInfo: RecyclerView.ItemAnimator.ItemHolderInfo): Boolean
Called by the RecyclerView when a ViewHolder has disappeared from the layout.
Link copied to clipboard
abstract fun animatePersistence(@NonNull viewHolder: RecyclerView.ViewHolder, @NonNull preLayoutInfo: RecyclerView.ItemAnimator.ItemHolderInfo, @NonNull postLayoutInfo: RecyclerView.ItemAnimator.ItemHolderInfo): Boolean
Called by the RecyclerView when a ViewHolder is present in both before and after the layout and RecyclerView has not received a notifyItemChanged call for it or a notifyDataSetChanged call.
Link copied to clipboard
open fun canReuseUpdatedViewHolder(@NonNull viewHolder: RecyclerView.ViewHolder, @NonNull payloads: List<Any>): Boolean
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.
Link copied to clipboard
Method to be called by subclasses when an animation is finished.
Link copied to clipboard
This method should be called by ItemAnimator implementations to notify any listeners that all pending and active item animations are finished.
Link copied to clipboard
Method to be called by subclasses when an animation is started.
Link copied to clipboard
Method called when an animation on a view should be ended immediately.
Link copied to clipboard
Method called when all item animations should be ended immediately.
Link copied to clipboard
Gets the current duration for which all add animations will run.
Link copied to clipboard
Gets the current duration for which all change animations will run.
Link copied to clipboard
Gets the current duration for which all move animations will run.
Link copied to clipboard
Gets the current duration for which all remove animations will run.
Link copied to clipboard
Method which returns whether there are any item animations currently running.
Like isRunning, this method returns whether there are any item animations currently running.
Link copied to clipboard
Returns a new ItemHolderInfo which will be used to store information about the ViewHolder.
Link copied to clipboard
Called after dispatchAnimationFinished is called by the ItemAnimator.
Link copied to clipboard
Called when a new animation is started on the given ViewHolder.
Link copied to clipboard
open fun recordPostLayoutInformation(@NonNull state: RecyclerView.State, @NonNull viewHolder: RecyclerView.ViewHolder): RecyclerView.ItemAnimator.ItemHolderInfo
Called by the RecyclerView after the layout is complete.
Link copied to clipboard
open fun recordPreLayoutInformation(@NonNull state: RecyclerView.State, @NonNull viewHolder: RecyclerView.ViewHolder, changeFlags: Int, @NonNull payloads: List<Any>): RecyclerView.ItemAnimator.ItemHolderInfo
Called by the RecyclerView before the layout begins.
Link copied to clipboard
Called when there are pending animations waiting to be started.
Link copied to clipboard
Sets the duration for which all add animations will run.
Link copied to clipboard
Sets the duration for which all change animations will run.
Link copied to clipboard
Sets the duration for which all move animations will run.
Link copied to clipboard
Sets the duration for which all remove animations will run.