用Lottie实现的动画效果

1.什么是Lottie
Lottie是Airbnb开源的一款面向Android,ios,react-native的动画库,可使用Adobe After Effects设计动画并导出json文件供开源库加载实现复杂动画效果.
2.Android使用Lottie
大概分为四步:引入Lottie库,添加动画文件,xml定义动画组件,加载动画文件播放动画.
2.1引入Lottie库
在build.gradle文件中引入Lottie库,最新版本可在github或官网查看
dependences{
implementation "com.airbnb.android:lottie:$lottieVersion" //需要将$lottieVersion替换为指定版本如3.4.1
}
2.2添加动画文件
将json文件添加到assets目录

2.3xml定义动画组件
可以在xml中指定要加载的动画文件,也可以代码指定,这里使用xml中指定

2.4加载动画文件播放动画
因为2.3中在xml中指定了动画文件所以播放动画就非常简单了,直接调用playAnimation方法就ok了

*本文用lottie实现了有动画效果的底部导航栏代码地址,喜欢的帮忙star下,非常感谢.关于Lottie更详细使用请参考github或官网
网友评论