其他分享
首页 > 其他分享> > Lottie简单设置动画过程

Lottie简单设置动画过程

作者:互联网

官方文档:https://github.com/airbnb/lottie-android

配置

implementation 'com.airbnb.android:lottie:$lottieVersion'

最简单的使用方法

在app/main/下 没有main的话直接在app文件夹下创建assets文件夹
在这里插入图片描述
然后将json文件放在其下 再创建一个images文件夹存放图片文件
在这里插入图片描述

在布局中直接使用


    <com.airbnb.lottie.LottieAnimationView
        android:id="@+id/lottie_main"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        app:lottie_fileName="immersive_feeling_create_gradients.json"
        app:lottie_imageAssetsFolder="images"
        app:lottie_loop="true"
        app:lottie_autoPlay="true" />

总结

首先在要使用动画的地方在布局文件中使用com.airbnb.lottie.LottieAnimationView这个空间,并指定其使用的动画json文件

在代码中获取控件,并直接通过animationView.setProgress(0f)设置当前动画的进度,使用animationView.playAnimation()来开起动画,使用animationView.cancelAnimation();来停止动画(在activity或者fragment生命周期中设置)

标签:动画,lottie,animationView,airbnb,设置,使用,Lottie,com
来源: https://blog.csdn.net/Azadoo/article/details/115668783