Skip to content
Spritz is an Android library to seamlessly trigger a Lottie animation
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Build status Download License

Spritz is an Android library to seamlessly trigger a Lottie animation when the user drags a ViewPager or changes page programmatically. It supports animating while swiping and auto-playing when the swipe is complete.

Read our blog post "Onboard your users with Lottie of Spritz" for more information.

Get the demo here:

Get it on Google Play

Here's how our demo looks like:

A taste of spritz

How to use

To use the library in your app, simply include the following Gradle dependency:

dependencies {


Each step in the ViewPager has two possible animations:

  • a "swipe away" animation that will be triggered while the user drags from one page to the next or previous one
  • an "autoplay" animation segment that plays as soon as the user enters the destination page

When swiping forward, the animation will stop right before auto-playing. When swiping backwards, instead, the animation will stop at the end of the previous page's autoplay animation, so it doesn't play again since that page is in an "already visited" state.

Lottie Animation

To learn how to create a Lottie-compatible animation from After Effects, please read our blog post "Whole Lottie Love", which contains basic instructions on how to export an animation into a Lottie-supported format.

Your animation should have:

  • for each page, a "swipe away" animation
  • for each page, optionally, an "autoplay" animation segment

These segments must be consecutive to one another, as if the user continuously moves to one page to another.


After getting your LottieAnimationView and your ViewPager, just create a Spritz object with the following syntax:

Spritz spritz = Spritz
                            new SpritzStep.Builder()
                                    .withAutoPlayDuration(500, TimeUnit.MILLISECONDS)
                                    .withSwipeDuration(500, TimeUnit.MILLISECONDS)
                            new SpritzStep.Builder()
                                    .withAutoPlayDuration(500, TimeUnit.MILLISECONDS)
                                    .withSwipeDuration(500, TimeUnit.MILLISECONDS)
                            new SpritzStep.Builder()
                                    .withAutoPlayDuration(500, TimeUnit.MILLISECONDS)

Once you have your Spritz instance, you need to simply attach it to the ViewPager, and start any pending animation. If you're working in an Activity, you would normally do it in onStart:

protected void onStart() {

When you're done with your view, detach the Spritz instance from the ViewPager:

protected void onStop() {

Animation durations

Spritz handles multiple types of animations for your view.

Note: this library assumes that the first set animation on the first page starts from the time 0, and that all animations are in the order [autoplay (optional) 0 - swipe 0 - ... - swipe (n-1) - autoplay (optional) n] and are consecutive to each other.

Autoplay animation

The autoplay animation is an optional animation that is launched automatically as soon as the ViewPager successfully transition to a new page. You simply need to set (using withAutoPlayDuration on the page builder) how long the autoplay animation lasts in your After Effects project, Spritz will take care of the rest.

Please note that the autoplay animation is always played after the user swipes forward, it is not played when the user swipes back, since the "swipe back" action sets the Lottie progress to the end of the previous autoplay animation.

Swipe animation

The swipe animation is started and progressed as the user drags the view pager back and forth. To set the duration of a page swipe animation, use withSwipeDuration. This animation is not optional, since it's what this library has been created for :P.

You can’t perform that action at this time.