android - android: 播放 Lottie 动画片段
问题描述
我认为问题的标题说明了一切,
我虽然想添加一个动画监听器,但无法得到我想要的结果。
//lottie_toggle is the view id
lottie_toggle.addAnimatorUpdateListener {valueAnimator->
val progress = (valueAnimator.animatedValue as Float * 100).toInt()
if (progress==100 ){
lottie_toggle.cancelAnimation()
lottie_toggle.progress=0f
}
if (progress==50 ){
lottie_toggle.cancelAnimation()
lottie_toggle.progress=0.5f
}
}
解决方案
似乎设置最小/最大帧是一种合适的方式,
//if the animation has 60 frames
lottie_toggle.setMinAndMaxFrame(0,30) //to play the first half
lottie_toggle.setMinAndMaxFrame(30,60) //to play the second half
推荐阅读
- java - 提高 Alog 的效率(将数组向左旋转 n 次迭代)
- php - 将 WooCommerce 自定义帐号字段值限制为仅限数字
- java - Android:NullPointerException'double java.lang.Double.doubleValue()'
- python - 从 PDF 中识别不可选择的图像
- excel - 希望下面的代码等同于带有格式的 Vlookup。有什么建议么。Excel VBA
- unity3d - 使用放大着色器进行框边界的横截面着色器
- blazor - 我可以结合服务器和客户端模型吗?
- sql - 在 Hive 中过滤掉字符串列的最佳方法是什么?
- tizen - 如何在tizen webapp中没有任何事件的情况下获得总累积步数?
- ms-access - 为什么通过脚本添加附件以访问数据库会产生错误