Android 12 Developer Preview is here! Try it out, and give us your feedback!

WindowInsetsAnimationControllerCompat

class WindowInsetsAnimationControllerCompat
kotlin.Any
   ↳ androidx.core.view.WindowInsetsAnimationControllerCompat

Controller for app-driven animation of system windows.

WindowInsetsAnimationController lets apps animate system windows such as the IME. The animation is synchronized, such that changes the system windows and the app's current frame are rendered at the same time.

Control is obtained through WindowInsetsControllerCompat#controlWindowInsetsAnimation.

Summary

Public methods
Unit
finish(shown: Boolean)

Finishes the animation, and leaves the windows shown or hidden.

Float

Current alpha value of the window.

Float

Returns the progress as previously set by fraction in setInsetsAndAlpha

Insets

Retrieves the current insets.

Insets

Retrieves the Insets when the windows this animation is controlling are fully hidden.

Insets

Retrieves the Insets when the windows this animation is controlling are fully shown.

Int

Boolean

Returns whether this instance has been cancelled by the system, or by invoking the android.os.CancellationSignal passed into WindowInsetsControllerCompat#controlWindowInsetsAnimation.

Boolean

Returns whether this instance has been finished by a call to finish.

Boolean

Returns whether this instance is ready to be used to control window insets.

Unit
setInsetsAndAlpha(@Nullable insets: Insets?, @FloatRange(0.0, 1.0) alpha: Float, @FloatRange(0.0, 1.0) fraction: Float)

Modifies the insets for the frame being drawn by indirectly moving the windows around in the system that are causing window insets.

Public methods

finish

fun finish(shown: Boolean): Unit

Finishes the animation, and leaves the windows shown or hidden.

After invoking finish, this instance is no longer ready.

Note: Finishing an animation implicitly sets insets and alpha according to the requested end state without any further animation.

Parameters
shown Boolean: if true, the windows will be shown after finishing the animation. Otherwise they will be hidden.

getCurrentAlpha

fun getCurrentAlpha(): Float

Current alpha value of the window.

Return
Float float value between 0 and 1.

getCurrentFraction

@FloatRange(0.0, 1.0) fun getCurrentFraction(): Float

Returns the progress as previously set by fraction in setInsetsAndAlpha

Return
Float the progress of the animation, where 0 is fully hidden and 1 is fully shown.

Note: this value represents raw overall progress of the animation i.e. the combined progress of insets and alpha.

getCurrentInsets

@NonNull fun getCurrentInsets(): Insets

Retrieves the current insets.

Note that these insets are always relative to the window, which is the same as being relative to View#getRootView

Return
Insets The current insets on the currently showing frame. These insets will change as the animation progresses to reflect the current insets provided by the controlled window.

getHiddenStateInsets

@NonNull fun getHiddenStateInsets(): Insets

Retrieves the Insets when the windows this animation is controlling are fully hidden.

Note that these insets are always relative to the window, which is the same as being relative to View#getRootView

If there are any animation listeners registered, this value is the same as WindowInsetsAnimationCompat.BoundsCompat#getLowerBound() that is being be passed into the root view of the hierarchy.

Return
Insets Insets when the windows this animation is controlling are fully hidden.

getShownStateInsets

@NonNull fun getShownStateInsets(): Insets

Retrieves the Insets when the windows this animation is controlling are fully shown.

Note that these insets are always relative to the window, which is the same as being relative to View#getRootView

If there are any animation listeners registered, this value is the same as WindowInsetsAnimationCompat.BoundsCompat#getUpperBound() that is being passed into the root view of hierarchy.

Return
Insets Insets when the windows this animation is controlling are fully shown.

getTypes

fun getTypes(): Int
Return
Int The Types this object is currently controlling.

isCancelled

fun isCancelled(): Boolean

Returns whether this instance has been cancelled by the system, or by invoking the android.os.CancellationSignal passed into WindowInsetsControllerCompat#controlWindowInsetsAnimation.

Return
Boolean true if the instance is cancelled, false otherwise.

See Also