androidanimationviewanimator

Android animate view along a curved path


I'm trying to move my image from one point to another using this answer to achieve my animation. However this animation is not showing. Below is the code I'm using

ArcTranslate animation = new ArcTranslate(1000,Animation.ABSOLUTE,fromPos[0],toPos[0],Animation.ABSOLUTE,fromPos[1],toPos[1]);
animation.start();

I'm having another doubt too. How does this animation figures out which view to animate? Does it just takes the view in the given fromPos??


Solution

  • You should attach the animation to a view. Usually, the following works well:

    View.startAnimation(animation);
    

    If you use this, remove the animation.start(). Alternatively you can first attach the animation, and start it later:

    View.setAnimation(animation);
    

    And then call animation.start() later.