다음을 통해 공유


WindowInsetsAnimation.Callback.OnPrepare(WindowInsetsAnimation) Method

Definition

Called when an insets animation is about to start and before the views have been laid out in the end state of the animation.

[Android.Runtime.Register("onPrepare", "(Landroid/view/WindowInsetsAnimation;)V", "GetOnPrepare_Landroid_view_WindowInsetsAnimation_Handler", ApiSince=30)]
public virtual void OnPrepare (Android.Views.WindowInsetsAnimation animation);
[<Android.Runtime.Register("onPrepare", "(Landroid/view/WindowInsetsAnimation;)V", "GetOnPrepare_Landroid_view_WindowInsetsAnimation_Handler", ApiSince=30)>]
abstract member OnPrepare : Android.Views.WindowInsetsAnimation -> unit
override this.OnPrepare : Android.Views.WindowInsetsAnimation -> unit

Parameters

animation
WindowInsetsAnimation

The animation that is about to start.

Attributes

Remarks

Called when an insets animation is about to start and before the views have been laid out in the end state of the animation. The ordering of events during an insets animation is the following:

<ul> <li>Application calls WindowInsetsController#hide(int), WindowInsetsController#show(int), WindowInsetsController#controlWindowInsetsAnimation</li> <li>onPrepare is called on the view hierarchy listeners</li> <li>View#onApplyWindowInsets will be called with the end state of the animation</li> <li>View hierarchy gets laid out according to the changes the application has requested due to the new insets being dispatched</li> <li>#onStart is called <em>before</em> the view hierarchy gets drawn in the new laid out state</li> <li>#onProgress is called immediately after with the animation start state</li> <li>The frame gets drawn.</li> </ul>

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 callback by using post-layout view properties like View#setX and related methods.

Note that the animation might be cancelled before #onStart is dispatched. On android.os.Build.VERSION_CODES#S S and later, #onEnd is immediately dispatched without an #onStart in that case. On android.os.Build.VERSION_CODES#R R, no callbacks are dispatched after #onPrepare for such an animation.

Note: If the animation is application controlled by using WindowInsetsController#controlWindowInsetsAnimation, the end state of the animation is undefined as the application may decide on the end state only by passing in shown parameter when calling WindowInsetsAnimationController#finish. In this situation, the system will dispatch the insets in the opposite visibility state before the animation starts. Example: When controlling the input method with WindowInsetsController#controlWindowInsetsAnimation and the input method is currently showing, View#onApplyWindowInsets will receive a WindowInsets instance for which WindowInsets#isVisible will return false for WindowInsets.Type#ime.

Java documentation for android.view.WindowInsetsAnimation.Callback.onPrepare(android.view.WindowInsetsAnimation).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to