Move image from left to right then rotate animation

前端 未结 1 839
抹茶落季
抹茶落季 2021-01-07 06:02

I\'m making an example that moving an image from left to right then rotate it self. I\'ve tried using AnimationSet but the image rotation isn\'t correct. It moves in a cycle

相关标签:
1条回答
  • 2021-01-07 06:41

    Try using this:

    RotateAnimation anim = new RotateAnimation(0f, 360f,
                        Animation.RELATIVE_TO_SELF, 0.5f,
                        Animation.RELATIVE_TO_SELF, 0.5f);
    

    So it will rotate relative to itself. Hope this helps.

    Edit:

    image.clearAnimation();
    RotateAnimation anim = new RotateAnimation(30, 360, image.getWidth()/2, image.getHeight()/2);
    anim.setFillAfter(true);
    anim.setRepeatCount(0);
    anim.setDuration(10000);
    image.startAnimation(anim); 
    

    I tested this one in demo application. Its working great. Hope this helps you :)

    0 讨论(0)
提交回复
热议问题