WindowInsetsAnimationControllerCompat
public final class 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 controlWindowInsetsAnimation.
Summary
Public methods |
|
|---|---|
void |
finish(boolean shown)Finishes the animation, and leaves the windows shown or hidden. |
float |
Current alpha value of the window. |
@FloatRange(from = 0.0, to = 1.0) float |
Returns the progress as previously set by |
@NonNull Insets |
Retrieves the current insets. |
@NonNull Insets |
Retrieves the |
@NonNull Insets |
Retrieves the |
int |
getTypes() |
boolean |
Returns whether this instance has been cancelled by the system, or by invoking the |
boolean |
Returns whether this instance has been finished by a call to |
boolean |
isReady()Returns whether this instance is ready to be used to control window insets. |
void |
setInsetsAndAlpha(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 void finish(boolean shown)
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 | |
|---|---|
boolean shown |
if |
getCurrentAlpha
public float getCurrentAlpha()
Current alpha value of the window.
| Returns | |
|---|---|
float |
float value between 0 and 1. |
getCurrentFraction
public @FloatRange(from = 0.0, to = 1.0) float getCurrentFraction()
Returns the progress as previously set by fraction in setInsetsAndAlpha
| Returns | |
|---|---|
@FloatRange(from = 0.0, to = 1.0) float |
the progress of the animation, where Note: this value represents raw overall progress of the animation i.e. the combined progress of insets and alpha. |
getCurrentInsets
public @NonNull Insets getCurrentInsets()
Retrieves the current insets.
Note that these insets are always relative to the window, which is the same as being relative to getRootView
getHiddenStateInsets
public @NonNull 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 getRootView
If there are any animation listeners registered, this value is the same as getLowerBound that is being be passed into the root view of the hierarchy.
| See also | |
|---|---|
getLowerBound |
getShownStateInsets
public @NonNull 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 getRootView
If there are any animation listeners registered, this value is the same as getUpperBound that is being passed into the root view of hierarchy.
| See also | |
|---|---|
getUpperBound |
getTypes
public int getTypes()
| Returns | |
|---|---|
int |
The |
isCancelled
public boolean isCancelled()
Returns whether this instance has been cancelled by the system, or by invoking the android.os.CancellationSignal passed into controlWindowInsetsAnimation.
| Returns | |
|---|---|
boolean |
|
| See also | |
|---|---|
onCancelled |
isFinished
public boolean isFinished()
Returns whether this instance has been finished by a call to finish.
| Returns | |
|---|---|
boolean |
|
| See also | |
|---|---|
onFinished |
isReady
public boolean isReady()
Returns whether this instance is ready to be used to control window insets.
Instances are ready when passed in onReady and stop being ready when it is either finished or cancelled.
| Returns | |
|---|---|
boolean |
|
setInsetsAndAlpha
public void setInsetsAndAlpha(
@Nullable Insets insets,
@FloatRange(from = 0.0, to = 1.0) float alpha,
@FloatRange(from = 0.0, to = 1.0) 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 getRootView
Also note that this will not inform the view system of a full inset change via 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 WindowInsetsAnimationCompat.Callback by calling setWindowInsetsAnimationCallback that will be notified about any insets change via onProgress during the animation.
dispatchApplyWindowInsets will instead be called once the animation has finished, i.e. once finish has been called. Note: If there are no insets, alpha animation is still applied.
| Parameters | |
|---|---|
@Nullable 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 |
@FloatRange(from = 0.0, to = 1.0) float alpha |
The new alpha to apply to the inset side. |
@FloatRange(from = 0.0, to = 1.0) float fraction |
instantaneous animation progress. This value is dispatched to |