安卓动画实现一边绕自身中心旋转一边移动所遇见的问题

AnimationSet animationSet = new AnimationSet(true);
//旋转
RotateAnimation rotateAnimation = new RotateAnimation( angles, angle, Animation. RELATIVE_TO_SELF, 0.5f, Animation. RELATIVE_TO_SELF, 0.5f); rotateAnimation.setDuration(tiem);
 
  
TranslateAnimation translateAnimation = new TranslateAnimation(
        //移动
    Animation.RELATIVE_TO_SELF, 0f,
    Animation.RELATIVE_TO_SELF, 0f,
    Animation.RELATIVE_TO_SELF, angles/140,
    Animation.RELATIVE_TO_SELF, angle / 140);
    translateAnimation.setDuration(100);
    animationSet.addAnimation(translateAnimation);
 
  
animationSet.addAnimation(rotateAnimation);
当先添加移动动画时,会出现图片并不绕自身中心旋转,无法达到想要的效果,解决方法:
只要先添加旋转动画再添加位移动画即可
animationSet.addAnimation(rotateAnimation);
 
  
  animationSet.addAnimation(translateAnimation);
 
  

你可能感兴趣的:(安卓动画实现一边绕自身中心旋转一边移动所遇见的问题)