Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 链接旋转动画不起作用_Android_Android Animation - Fatal编程技术网

Android 链接旋转动画不起作用

Android 链接旋转动画不起作用,android,android-animation,Android,Android Animation,我试图用旋转来给人一种左右摇晃的感觉。我尝试以编程方式定义动画,并使用animationset循环它,如中所建议的那样。然而,在执行时,代码似乎什么都没有做 AnimationSet set = new AnimationSet(true); RotateAnimation rotright = new RotateAnimation(0.0f, 20.0f, Animation.RELATIVE_TO_SELF, 0.9f, Animation.RELATIVE_TO_SEL

我试图用旋转来给人一种左右摇晃的感觉。我尝试以编程方式定义动画,并使用animationset循环它,如中所建议的那样。然而,在执行时,代码似乎什么都没有做

AnimationSet set = new AnimationSet(true);

RotateAnimation rotright = new RotateAnimation(0.0f, 20.0f,
        Animation.RELATIVE_TO_SELF, 0.9f, Animation.RELATIVE_TO_SELF, 0.5f);
rotright.setDuration(0);
set.addAnimation(rotright);

RotateAnimation rotleft = new RotateAnimation(0.0f, 340.0f,
        Animation.RELATIVE_TO_SELF, 0.9f, Animation.RELATIVE_TO_SELF, 0.5f);
rotleft.setDuration(0);
set.addAnimation(rotleft);

blender.startAnimation( set );
}
};
任何关于我到底把事情搞砸了的线索都将不胜感激

rotright.setDuration(0);

rotleft.setDuration(0);

您已经将两个动画的持续时间设置为
0
,有效地创建了即时旋转,这将导致根本没有动画。尝试设置一些大于零的值-记住您设置的是毫秒。

非常感谢。如果我可以扩展我的问题,它仍然没有循环。知道为什么吗?@user1398478:你的
动画集设置好了吗?我在您的原始代码片段中没有看到它。您可以传入
动画。重新启动
动画。反转
,具体取决于所需效果。