0

I found out that the movement of an image between two point can be achieved with this simple code:

    ImageView image_to_move = (ImageView) findViewById(R.id.image_to_move); 
    TranslateAnimation animation = new TranslateAnimation(50, 100, 50, 100);
    animation.setDuration(5000);     
    image_to_move.startAnimation(animation);

The image is an ImageView set initially in position (0,0) inside a FrameLayout and the code move it from the point (50,50) to (100,100). What if i have to move it on a path, made of several point, in the form of absolute coordinate (x,y)? For example, move from (50,50) to (75,75) then to (100,100) There's a way to pass to the translating function an array of coordinate or i have simply to iterate the animation for every couple of points?

Btw, i saw that if i don't initially locate the image in (0,0) the function moves the image in a weird way, like the coordinate i give are not read as absolute. Am i missing something? EDIT: The last thing happens when i pass as parameters to the TranslateAnimation something like "n92.getX()" where n92 is a button on my frame layout, from which position i want the animation to start. DETAIL: Just to understand better the problem: I am implementing the animation of a point moving on a map, to show the user how to get from one point to another of a map. That's why i have absolute coordinate (the reachable points) that must be followed (you can't arrive from one point to another without following a precise path on the map)

Sasha Grievus
  • 2,566
  • 5
  • 31
  • 58

1 Answers1

0

to do so you need to Calculate the position on a quadratic bezier curve. try this answer it might be work for you

Community
  • 1
  • 1
Maulik.J
  • 636
  • 1
  • 6
  • 14
  • but i don't need it to move on a curved path. Instead i need it to move on lines between several point: an ugly but functional squared path ^^ – Sasha Grievus Apr 02 '14 at 12:32