首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不带持续时间的RotateAnimation

不带持续时间的RotateAnimation
EN

Stack Overflow用户
提问于 2011-06-02 21:21:02
回答 2查看 9K关注 0票数 6

伙计们。我有这个代码(asyncTask)

我的动画()函数:

代码语言:javascript
复制
public void animation()
        {
        int   currentRotation = 0;
            anim = new RotateAnimation(currentRotation, (360*4),
                    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f);
            currentRotation = (currentRotation + 45) % 360;
            anim.setInterpolator(new LinearInterpolator());
            anim.setDuration(4000);// i want rotating without this <------------------
            anim.setFillEnabled(true);
            anim.setFillAfter(true);
            refresh.startAnimation(anim);
        }

有人能告诉我,没有anim.setDuration也是可能的吗?才刚刚开始..例如,当我按下按钮时,动画就停止了。请帮帮我。打招呼,彼得。

最终代码:

代码语言:javascript
复制
 public void animation()
            {
            int   currentRotation = 0;
                anim = new RotateAnimation(currentRotation, (360*4),
                        Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f);
                currentRotation = (currentRotation + 45) % 360;
                anim.setInterpolator(new LinearInterpolator());
                anim.setDuration(4000);
               // anim.setRepeatMode(Animation.INFINITE);
                anim.setRepeatCount(Animation.INFINITE);
                anim.setFillEnabled(true);
                anim.setFillAfter(true);
                refresh.startAnimation(anim);
            }

和某处refresh.clearAnimation();的停止动画,它是我的工作完美..如果这里有什么问题-请告诉我..无论如何,感谢您的回答:)

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-06-02 21:26:57

我认为你应该看看重复模式。持续时间是在动画中循环一次的时间,如果您将其设置为在此之后重复,则它可以永远继续下去。参见thisthat

例如,您可以使用:

代码语言:javascript
复制
anim.setRepeatCount(Animation.INFINITE);
anim.setRepeatMode(Animation.RESTART);
票数 12
EN

Stack Overflow用户

发布于 2017-11-01 13:26:31

正如PearsonArtPhoto建议的那样,您应该查看重复模式。持续时间是在动画中循环一次的时间,如果您将其设置为在此之后重复,则它可以永远继续下去。

使用ObjectAnimator来实现效果。例如,您可以使用:

代码语言:javascript
复制
anim.setRepeatCount(Animation.INFINITE);
anim.setRepeatMode(ValueAnimator.RESTART); //note the difference here
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6215074

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档