简体   繁体   English

android:玩乐蒂animation的片段

[英]android: play segment of Lottie animation

I think the title of the question says it all,我认为问题的标题说明了一切,

I though of adding an animation Listener but couldn't get the result i want.我虽然想添加一个 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
        }
    }

it appears that setting the min/max frame is a suitable way,似乎设置最小/最大帧是一种合适的方式,

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

It sets the maximum progress that the animation will end at when playing or looping.它设置 animation 在播放或循环时将结束的最大进度。

lottie_toggle.setMaxFrame(maxFrame);

It sets the minimum frame that the animation will start from when playing or looping.它设置 animation 在播放或循环时开始的最小帧。

lottie_toggle.setMinFrame(minFrame);

It sets the minimum and maximum frames that the animation will start and end when playing or looping.它设置 animation 在播放或循环时将开始和结束的最小和最大帧。

lottie_toggle.setMinAndMaxFrame(minFrame, maxFrame);

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

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