Before saying that it's duplicate please note that I searched for a solution with no luck, I looked at this: android objectanimator expand/collapse from top to bottom animation?
but it doesn't really solves my problem.
I have a game which lets the user assemble the image to get the result.
Since the image is sliced up to small ones in order to assemble them.
What I need is when I click on one of the images, I want it to move from the old position to the new position in a sliding animation.
this is my code and it works just fine:
private ObjectAnimator GetConfiguration(ImageView s , ImageView d)
{
// get coordination
int[]xy = new int[2];
d.getLocationOnScreen(xy);
int d_x = xy[0];
int d_y = xy[1];
s.getLocationOnScreen(xy);
int s_x = xy[0];
int s_y = xy[1];
// source
//some code here that I deleted since it's not important
// check if right of it
if(tag_s_l == tag_d_l) // same row
{
// check if right or left now
if(tag_s_r == (tag_d_r + 1)) // from right to left
{
return ObjectAnimator.ofFloat(s, "translationX", d_x-s_x, 0);
}
else
{
return ObjectAnimator.ofFloat(s, "translationX", -(s_x-d_x),0);
}
}
if(tag_s_l == (tag_d_l + 1)) // down to top
{
return ObjectAnimator.ofFloat(s, "translationY", -(s_y-d_y),0);
}
else
{
return ObjectAnimator.ofFloat(s, "translationY", d_y-s_y, 0);
}
}
I deleted some of the code so you can read it faster. basically I'm getting the x and y of the two images and move one to the other.
This code works only for x 'horizontal' and it gives me the sliding animation I want, however when I move vertically 'y' it gives me and expand/collapse animation, but I want the sliding animation, not this!
Update: Pics.
Here are pics of the problem, the first picture shows the original position of the small images, then I set the duration to 10 seconds so it would be clear,
http://oi57.tinypic.com/2qxryw0.jpg
this is the first pic , it shows the images with their initial position.
http://oi59.tinypic.com/14ac0p5.jpg
now here's a second image when I click the image that is to the left of the transparent image " the black one " so I can move to right, at the same time I clicked the top image of the image that we moved. As you can see the image that gone from left to right is moving in a sliding animation, where is the top one is disappearing , then appears like an expand animation. but I want a sliding animation for both sides!