Gradle is the only supported build configuration, so just add the dependency to your project build.gradle
file:
dependencies { compile 'com.airbnb.android:lottie-android:1.0.0' }
Lottie animations are rendered by LottieAnimationView
. LottieAnimationView
animations are defined by a LottieComposition
. You can load a composition directly with LottieComposition.fromFile(...)
which will look in src/main/assets
or LottieComposition.fromJson(...)
if you have a raw JSONObject (useful for loading animations from the newtork).
However, the simplest way to use it is with an xml attribute or to let LottieAnimationView load the composition:
<com.airbnb.lottie.LottieAnimationView android:id="@+id/animation_view" android:layout_width="wrap_content" android:layout_height="wrap_content" app:lottie_fileName="hello-world.json" app:lottie_loop="true"/>
Or you can load it programatically:
LottieAnimationView animationView = findViewById(R.id.animation_view); animationView.setAnimation("hello-world.json"); animationView.loop(true); animationView.playAnimation();
Lottie is named after a German film director and the foremost pioneer of silhouette animation. Her best known films are The Adventures of Prince Achmed (1926) – the oldest surviving feature-length animated film, preceding Walt Disney's feature-length Snow White and the Seven Dwarfs (1937) by over ten years The art of Lotte Reineger
##Try it out Clone this repository and run the LottieSample module to see a bunch of sample animations. The JSON files for them are located in /assets.
Contributers are more than welcome. Just upload a PR with a description of your changes. Lottie uses Facebook screenshot tests for Android to identify pixel level changes/breakages. Please run ./gradlew --daemon recordMode screenshotTests
before uploading a PR to ensure that nothing has broken.
If you would like to add more JSON files and screenshot tests, feel free to do so and add the test to LottieTest
.