WindowInsetsAnimationCompat

Added in 1.5.0

public final class WindowInsetsAnimationCompat


Class representing an animation of a set of windows that cause insets.

Summary

Nested types

Class representing the range of an WindowInsetsAnimationCompat

Interface that allows the application to listen to animation events for windows that cause insets.

Public constructors

WindowInsetsAnimationCompat(
    int typeMask,
    @Nullable Interpolator interpolator,
    long durationMillis
)

Creates a new WindowInsetsAnimationCompat object.

Public methods

@FloatRange(from = 0.0, to = 1.0) float

Retrieves the translucency of the windows that are animating.

long
@FloatRange(from = 0.0, to = 1.0) float

Returns the raw fractional progress of this animation between start state of the animation and the end state of the animation.

float

Returns the interpolated fractional progress of this animation between start state of the animation and the end state of the animation.

@Nullable Interpolator

Retrieves the interpolator used for this animation, or null if this animation doesn't follow an interpolation curved.

int
void
setAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha)

Sets the translucency of the windows that are animating.

void
setFraction(@FloatRange(from = 0.0, to = 1.0) float fraction)

Set fraction of the progress if Type animation is controlled by the app.

Public constructors

WindowInsetsAnimationCompat

Added in 1.5.0
public WindowInsetsAnimationCompat(
    int typeMask,
    @Nullable Interpolator interpolator,
    long durationMillis
)

Creates a new WindowInsetsAnimationCompat object.

This should only be used for testing, as usually the system creates this object for the application to listen to with WindowInsetsAnimationCompat.Callback.

Parameters
int typeMask

The bitmask of WindowInsetsCompat.Types that are animating.

@Nullable Interpolator interpolator

The interpolator of the animation.

long durationMillis

The duration of the animation in MILLISECONDS.

Public methods

getAlpha

Added in 1.5.0
public @FloatRange(from = 0.0, to = 1.0) float getAlpha()

Retrieves the translucency of the windows that are animating.

Returns
@FloatRange(from = 0.0, to = 1.0) float

Alpha of windows that cause insets of type Type.

getDurationMillis

Added in 1.5.0
public long getDurationMillis()
Returns
long

duration of animation in MILLISECONDS, or -1 if the animation doesn't have a fixed duration.

getFraction

Added in 1.5.0
public @FloatRange(from = 0.0, to = 1.0) float getFraction()

Returns the raw fractional progress of this animation between start state of the animation and the end state of the animation. Note that this progress is the global progress of the animation, whereas onProgress will only dispatch the insets that may be inset with inset by parents of views in the hierarchy. Progress per insets animation is global for the entire animation. One animation animates all things together (in, out, ...). If they don't animate together, we'd have multiple animations.

Note: In case the application is controlling the animation, the valued returned here will be the same as the application passed into setInsetsAndAlpha.

Returns
@FloatRange(from = 0.0, to = 1.0) float

The current progress of this animation.

getInterpolatedFraction

Added in 1.5.0
public float getInterpolatedFraction()

Returns the interpolated fractional progress of this animation between start state of the animation and the end state of the animation. Note that this progress is the global progress of the animation, whereas onProgress will only dispatch the insets that may be inset with inset by parents of views in the hierarchy. Progress per insets animation is global for the entire animation. One animation animates all things together (in, out, ...). If they don't animate together, we'd have multiple animations.

Note: In case the application is controlling the animation, the valued returned here will be the same as the application passed into setInsetsAndAlpha, interpolated with the interpolator passed into controlWindowInsetsAnimation.

Note: For system-initiated animations, this will always return a valid value between 0 and 1.

Returns
float

The current interpolated progress of this animation.

See also
getFraction

for raw fraction.

getInterpolator

Added in 1.5.0
public @Nullable Interpolator getInterpolator()

Retrieves the interpolator used for this animation, or null if this animation doesn't follow an interpolation curved. For system-initiated animations, this will never return null.

Returns
@Nullable Interpolator

The interpolator used for this animation.

getTypeMask

Added in 1.5.0
public int getTypeMask()
Returns
int

The bitmask of Type that are animating.

setAlpha

Added in 1.5.0
public void setAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha)

Sets the translucency of the windows that are animating.

Note: This should only be used for testing, as the system fills in the alpha for the application or the alpha that was passed into setInsetsAndAlpha is being used.

Parameters
@FloatRange(from = 0.0, to = 1.0) float alpha

Alpha of windows that cause insets of type Type.

See also
getAlpha

setFraction

Added in 1.5.0
public void setFraction(@FloatRange(from = 0.0, to = 1.0) float fraction)

Set fraction of the progress if Type animation is controlled by the app.

Note: This should only be used for testing, as the system fills in the fraction for the application or the fraction that was passed into setInsetsAndAlpha is being used.

Parameters
@FloatRange(from = 0.0, to = 1.0) float fraction

fractional progress between 0 and 1 where 0 represents hidden and zero progress and 1 represent fully shown final state.

See also
getFraction