ViewTreeObserver.WindowInsetsAnimationListener
public
static
interface
ViewTreeObserver.WindowInsetsAnimationListener
| android.view.ViewTreeObserver.WindowInsetsAnimationListener |
Interface definition for a callback to be invoked when window insets animations prepare or end.
A window insets animation listener can be registered to observe when window insets animations are about to start (prepare) and when they end. These callbacks are executed on the UI thread.
Unlike WindowInsetsAnimation.Callback, which is designed for applications to
synchronize their view layouts or draw frames with the animation on every frame, this
listener only observes the preparation and completion of animations, but doesn't allow for
frame-by-frame synchronization.
Because this listener does not perform frame-by-frame synchronization, registering only
this listener without a corresponding WindowInsetsAnimation.Callback on the view
hierarchy allows the window insets animation to run off-thread on the background animation
thread. This avoids the performance overhead of running the animation on the main UI
thread.
This listener does not have an equivalent to
WindowInsetsAnimation.Callback.onStart or receive the animation bounds,
because it is not intended for layout synchronization. To perform frame-synchronized layout
changes or customize the animation bounds, register a WindowInsetsAnimation.Callback
on the view hierarchy instead.
See also:
Summary
Public methods | |
|---|---|
default
void
|
onEnd(WindowInsetsAnimation animation)
Called after a window insets animation has ended. |
default
void
|
onPrepare(WindowInsetsAnimation animation)
Called when an insets animation is about to start and before the views have been laid out in the end state of the animation. |
Public methods
onEnd
public void onEnd (WindowInsetsAnimation animation)
Called after a window insets animation has ended.
| Parameters | |
|---|---|
animation |
WindowInsetsAnimation: The animation that has ended.
This value cannot be null. |
onPrepare
public void onPrepare (WindowInsetsAnimation animation)
Called when an insets animation is about to start and before the views have been laid out in the end state of the animation.
This is called before the final insets are dispatched to the view hierarchy via
View.onApplyWindowInsets or View.OnApplyWindowInsetsListener.
| Parameters | |
|---|---|
animation |
WindowInsetsAnimation: The animation that is about to start.
This value cannot be null. |