WindowInsetsAnimationCompat.Callback

public static abstract class WindowInsetsAnimationCompat.Callback
extends Object

java.lang.Object
   ↳ androidx.core.view.WindowInsetsAnimationCompat.Callback


Interface that allows the application to listen to animation events for windows that cause insets.

Summary

Constants

int DISPATCH_MODE_CONTINUE_ON_SUBTREE

Return value for getDispatchMode(): Dispatching of animation events should continue in the view hierarchy.

int DISPATCH_MODE_STOP

Return value for getDispatchMode(): Dispatching of animation events should stop at this level in the view hierarchy, and no animation events should be dispatch to the subtree of the view hierarchy.

Public constructors

Callback(int dispatchMode)

Creates a new WindowInsetsAnimationCompat callback with the given dispatch mode.

Public methods

final int getDispatchMode()

Retrieves the dispatch mode of this listener.

void onEnd(WindowInsetsAnimationCompat animation)

Called when an insets animation has ended.

void onPrepare(WindowInsetsAnimationCompat animation)

Called when an insets animation is about to start and before the views have been re-laid out due to an animation.

abstract WindowInsetsCompat onProgress(WindowInsetsCompat insets, List<WindowInsetsAnimationCompat> runningAnimations)

Called when the insets change as part of running an animation.

WindowInsetsAnimationCompat.BoundsCompat onStart(WindowInsetsAnimationCompat animation, WindowInsetsAnimationCompat.BoundsCompat bounds)

Called when an insets animation gets started.

Inherited methods

Constants

DISPATCH_MODE_CONTINUE_ON_SUBTREE

public static final int DISPATCH_MODE_CONTINUE_ON_SUBTREE

Return value for getDispatchMode(): Dispatching of animation events should continue in the view hierarchy.

Constant Value: 1 (0x00000001)

DISPATCH_MODE_STOP

public static final int DISPATCH_MODE_STOP

Return value for getDispatchMode(): Dispatching of animation events should stop at this level in the view hierarchy, and no animation events should be dispatch to the subtree of the view hierarchy.

Constant Value: 0 (0x00000000)

Public constructors

Callback

public Callback (int dispatchMode)

Creates a new WindowInsetsAnimationCompat callback with the given dispatch mode.

Parameters
dispatchMode int: The dispatch mode for this callback. See getDispatchMode().

Public methods

getDispatchMode

public final int getDispatchMode ()

Retrieves the dispatch mode of this listener. Dispatch of the all animation events is hierarchical: It will starts at the root of the view hierarchy and then traverse it and invoke the callback of the specific View that is being traversed. The method may return either DISPATCH_MODE_CONTINUE_ON_SUBTREE to indicate that animation events should be propagated to the subtree of the view hierarchy, or DISPATCH_MODE_STOP to stop dispatching. In that case, all animation callbacks related to the animation passed in will be stopped from propagating to the subtree of the hierarchy.

Also note that DISPATCH_MODE_STOP behaves the same way as returning WindowInsetsCompat.CONSUMED during the regular insets dispatch in View.onApplyWindowInsets(WindowInsets).

Returns
int Either DISPATCH_MODE_CONTINUE_ON_SUBTREE to indicate that dispatching of animation events will continue to the subtree of the view hierarchy, or DISPATCH_MODE_STOP to indicate that animation events will stop dispatching.

onEnd

public void onEnd (WindowInsetsAnimationCompat animation)

Called when an insets animation has ended.

Parameters
animation WindowInsetsAnimationCompat: The animation that has ended. This will be the same instance as passed into onStart(WindowInsetsAnimationCompat, WindowInsetsAnimationCompat.BoundsCompat)

onPrepare

public void onPrepare (WindowInsetsAnimationCompat animation)

Called when an insets animation is about to start and before the views have been re-laid out due to an animation.

This ordering allows the application to inspect the end state after the animation has finished, and then revert to the starting state of the animation in the first onProgress(WindowInsetsCompat, List) callback by using post-layout view properties like View.setX(float) and related methods.

The ordering of events during an insets animation is the following: