赞
踩
今天用了一下,给我的感觉,还是值得推荐的,lottie官方文档地址
github地址,做到以下四个发方法,基本就可以使用了
使用lottie的时候,碰到一个错误(You must set an images folder before loading an image)
java.lang.IllegalStateException:
You must set an images folder before loading an image. Set it with LottieComposition#setImagesFolder or LottieDrawable#setImagesFolder
导入库
compile 'com.airbnb.android:lottie:2.2.0'
主要操作
lottieAnimationView.setImageAssetsFolder("images");//设置data.json引用的图片资源文件夹名称,如果没有可不写
lottieAnimationView.setAnimation("data.json");//通过AE生成的图文件(json格式)
lottieAnimationView.loop(true);//设置循环动画
lottieAnimationView.playAnimation();//开始动画
setImageAssetsFolder方法,进去看源码,就是如果要使用到image资源,需要明确指定assets下的文件夹是哪一个;下边还举了一个例子
/**
* If you use image assets, you must explicitly specify the folder in assets/ in which they are
* located because bodymovin uses the name filenames across all compositions (img_#).
* Do NOT rename the images themselves.
*
* If your images are located in src/main/assets/airbnb_loader/ then call
* `setImageAssetsFolder("airbnb_loader/");`.
*/
public void setImageAssetsFolder(String imageAssetsFolder) {
lottieDrawable.setImagesAssetsFolder(imageAssetsFolder);
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。