我想旋转一个 ImageView。但我想从 0 旋转到 45 到 -45,然后返回 0 来总结我的目标。
我尝试创建 4rotationAnimation并将它们与AnimatorSet.
这是我的代码:
rotate = new RotateAnimation(0, 45, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotate.setDuration(1000);
rotate.setInterpolator(new LinearInterpolator());
rotate1 = new RotateAnimation(45, -45, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotate1.setDuration(1000);
rotate1.setInterpolator(new LinearInterpolator());
rotate2 = new RotateAnimation(-45, 45, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotate2.setDuration(1000);
rotate2.setInterpolator(new LinearInterpolator());
rotate3 = new RotateAnimation(45, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotate3.setDuration(1000);
rotate3.setInterpolator(new LinearInterpolator());
setAnim= new AnimationSet(true);
setAnim.addAnimation(rotate);
setAnim.addAnimation(rotate1);
setAnim.addAnimation(rotate2);
setAnim.addAnimation(rotate3);
img.startAnimation(setAnim);
目前图像突然没有旋转到 45° 并返回到 0°。
青春有我
月关宝盒
相关分类