文章目录
1.初始化本地zip文件
LottieCompositionFactory.fromZipStream(
ZipInputStream(FileInputStream("/storage/emulated/0/Android/data/packageName/files/test.zip")),
"test"
)
.addListener {
testLottieAnimationView.setComposition(it)
testLottieAnimationView.playAnimation()
}
2.加载本地字体资源
testLottieAnimationView.setFontAssetDelegate(object : FontAssetDelegate() {
override fun fetchFont(fontFamily: String?): Typeface {
return Typeface.createFromFile("/storage/emulated/0/Android/data/packageName/files/Hei.ttf")
}
override fun getFontPath(fontFamily: String?): String {
return "/storage/emulated/0/Android/data/packageName/files/Hei.ttf"
}
})
3.设置Lottie动画中的文本 替换对应的key
这个key是设计那边指定好的 具体是什么可以问一下
val textDelegate = TextDelegate(testLottieAnimationView)
textDelegate.setText("key", "要设置的文本")
4.设置Lottie动画中图片
testLottieAnimationView.updateBitmap( "key", bitmap)
其中bitmap可以自己转