# Print output for @column tags ?> WindowInsetsAnimationController - Android SDK | Android Developers

Most visited

Recently visited

WindowInsetsAnimationController

public interface WindowInsetsAnimationController

android.view.WindowInsetsAnimationController


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 WindowInsetsController#controlWindowInsetsAnimation.

Summary

Public methods

abstract void finish(boolean shown)

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

abstract float getCurrentAlpha()

Current alpha value of the window.

abstract float getCurrentFraction()

Returns the progress as previously set by fraction in setInsetsAndAlpha(Insets, float, float)

abstract Insets getCurrentInsets()

Retrieves the current insets.

abstract Insets getHiddenStateInsets()

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

abstract Insets getShownStateInsets()

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

abstract int getTypes()
abstract boolean isCancelled()

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

abstract boolean isFinished()

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

default boolean isReady()

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

abstract void setInsetsAndAlpha(Insets insets, float alpha, float fraction)

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

public abstract void finish (boolean shown)

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

After invoking finish(boolean), 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

public abstract float getCurrentAlpha ()

Current alpha value of the window.

Returns
float float value between 0 and 1.

getCurrentFraction

public abstract float getCurrentFraction ()

Returns the progress as previously set by fraction in setInsetsAndAlpha(Insets, float, float)

Returns
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.

Value is between 0f and 1f inclusive

getCurrentInsets

public abstract Insets getCurrentInsets ()

Retrieves the current insets.

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

Returns
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. This value cannot be null.

getHiddenStateInsets

public abstract Insets getHiddenStateInsets ()

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 Bounds#getLowerBound() that is being be passed into the root view of the hierarchy.

Returns
Insets Insets when the windows this animation is controlling are fully hidden. This value cannot be null.

See also:

getShownStateInsets

public abstract Insets getShownStateInsets ()

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 Bounds#getUpperBound() that is being passed into the root view of hierarchy.

Returns
Insets Insets when the windows this animation is controlling are fully shown. This value cannot be null.

See also:

getTypes

public abstract int getTypes ()

Returns
int The WindowInsets.Types this object is currently controlling. Value is either 0 or a combination of android.view.WindowInsets.Type.STATUS_BARS, android.view.WindowInsets.Type.NAVIGATION_BARS, android.view.WindowInsets.Type.CAPTION_BAR, android.view.WindowInsets.Type.IME, android.view.WindowInsets.Type.WINDOW_DECOR, android.view.WindowInsets.Type.SYSTEM_GESTURES, android.view.WindowInsets.Type.MANDATORY_SYSTEM_GESTURES, android.view.WindowInsets.Type.TAPPABLE_ELEMENT, and android.view.WindowInsets.Type.DISPLAY_CUTOUT

isCancelled

public abstract boolean isCancelled ()

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

Returns
boolean true if the instance is cancelled, false otherwise.

See also:

isFinished

public abstract boolean isFinished ()

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

Returns
boolean true if the instance is finished, false otherwise.

See also:

isReady

public boolean isReady ()

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

Instances are ready when passed in WindowInsetsAnimationControlListener#onReady and stop being ready when it is either finished or cancelled.

Returns
boolean true if the instance is ready, false otherwise.

setInsetsAndAlpha

public abstract void setInsetsAndAlpha (Insets insets, 
                float alpha, 
                float fraction)

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

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

Also note that this will not inform the view system of a full inset change via View#dispatchApplyWindowInsets in order to avoid a full layout pass during the animation. If you'd like to animate views during a window inset animation, register a WindowInsetsAnimation.Callback by calling View#setWindowInsetsAnimationCallback(WindowInsetsAnimation.Callback) that will be notified about any insets change via WindowInsetsAnimation.Callback#onProgress during the animation.

View#dispatchApplyWindowInsets will instead be called once the animation has finished, i.e. once finish(boolean) has been called. Note: If there are no insets, alpha animation is still applied.

Parameters
insets Insets: The new insets to apply. Based on the requested insets, the system will calculate the positions of the windows in the system causing insets such that the resulting insets of that configuration will match the passed in parameter. Note that these insets are being clamped to the range from getHiddenStateInsets() to getShownStateInsets(). If you intend on changing alpha only, pass null or getCurrentInsets(). This value may be null.

alpha float: The new alpha to apply to the inset side. Value is between 0f and 1f inclusive

fraction float: instantaneous animation progress. This value is dispatched to WindowInsetsAnimation.Callback. Value is between 0f and 1f inclusive

See also: