Use the `Lottie Animation` using the following steps:
Add the **Gradle** dependency to your app
dependencies {
implementation 'com.airbnb.android:lottie:2.7.0'
}
Add the view to Your **Layout XML**:
<com.airbnb.lottie.LottieAnimationView
android:layout_width="wrap_conten"
android:layout_height="wrap_conten"
app:lottie_fileName="no_connection.json" //this is the JSON animation stored in assets folder
app:lottie_autoPlay="true"
app:lottie_loop="true"/>
In your Activity or Fragment init the view:
private LottieAnimationView animationView;
animationView = (LottieAnimationView) findViewById(R.id.animation_view);
if use form url :
animationView.setAnimationFromUrl ("https://assets10.lottiefiles.com/datafiles/c56b08b89932c090a0948b53fd58427d/data.json")
**Play/Cancel** the Animation using:
animationView.playAnimation();
animationView.cancelAnimation();
Use the Lottie Animation using the following steps:
Add the Gradle dependency to your app
dependencies {
compile 'com.airbnb.android:lottie:2.2.0'
}
Add the view to Your Layout XML:
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/animation_view"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:lottie_fileName="preloader.json"//this is the JSON animation stored in assets folder
app:lottie_loop="true"
app:lottie_autoPlay="true" />
In your Activity or Fragment init the view:
private LottieAnimationView animationView;
animationView = (LottieAnimationView) findViewById(R.id.animation_view);
Play/Cancel the Animation using:
animationView.playAnimation();
animationView.cancelAnimation();