繁体   English   中英

android:玩乐蒂animation的片段

[英]android: play segment of Lottie animation

我认为问题的标题说明了一切,

我虽然想添加一个 animation 监听器,但无法得到我想要的结果。

     //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

它设置 animation 在播放或循环时将结束的最大进度。

lottie_toggle.setMaxFrame(maxFrame);

它设置 animation 在播放或循环时开始的最小帧。

lottie_toggle.setMinFrame(minFrame);

它设置 animation 在播放或循环时将开始和结束的最小和最大帧。

lottie_toggle.setMinAndMaxFrame(minFrame, maxFrame);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM