Learning Android Development

Android Jetpack Compose: DecayAnimationSpec Made Easy

Make Learning Jetpack Compose Easy

Photo by Tim Carey on Unsplash

I previously shared about Android Jetpack Compose AnimationSpec and illustrate it with auto plotted graph as per in the particle below.

The AnimationSpec provides us the ability to define what the progressing animation computed result will be, with a target end animated result (e.g. the alpha value, we can animate from 0 to 0.5 to 1 and to any other value).

animatable.animateTo(targetValue, animationSpec)

However, at times, there are some animations that we should not have control over the end result, but only having the initial velocity provided to it, e.g. the Fling behavior.

For such animation, we will need to provide them DecayAnimationSpec.

animatable.animateDecay(initialVelocity, decayAnimationSpec)

Provide DecayAnimationSpec

--

--