我正在开发一个带有 Lottie 动画的应用程序。抽签动画之一需要两个图像文件(img_0.png,img1_.png)。
例如,
lottie json file [ data.json ] : {"v":"5.1.7","fr":60,"ip":0,"op":120,"w":180,"h":200,"nm":"2","ddd":0,"assets":[{"id":"image_0","w":96,"h":96,"u":"images/","p":"img_0.png"},{"id":"image_1","w":180,"h":180,"u":"images/","p":"img_1.png"}],....
我无法在 main/assets 文件夹中为 LottieAnimationView 准备所有图像,因此我使用“setImageAssetDelegate”方法从 URL 异步获取多个图像。
这是我的代码:
Glide.with(this)
.asBitmap()
.load("https://www.google.co.kr/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png")
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(final Bitmap resource, Transition<? super Bitmap> transition) {
LottieAnimationView lottie = findViewById(R.id.lottie);
lottie.setImageAssetDelegate(new ImageAssetDelegate() {
@Override
public Bitmap fetchBitmap(LottieImageAsset asset) {
return resource;
}
});
lottie.playAnimation();
}
});
但是如果我使用“setImageAssetDelegate”方法,我只能将一张图像放到 Lottie。我想在一个 Lottie 动画中放置多个不同的图像。
我不想要这个。(上面的代码显示了这个动画)。
我需要使用“setImageAssetDelegate”方法。
有人对此有任何想法吗?