i wanned to move a imageview from source(Bee) to destination(Flowers) like in this image: http://postimg.org/image/np069wui3/
but i cant get the result im doing this to move it
for (int i = 0; i < List_Position.size(); i++) {
int[] posXY = new int[2];
img_main[List_Position.get(i)].getLocationOnScreen(posXY);
int x = posXY[0]+img_main[List_Position.get(i)].getWidth()/2;
int y = posXY[1]+img_main[List_Position.get(i)].getHeight()/2;
Position_X.add(x);
Position_Y.add(y);
}
// to animate an image view i did this
Animation animation = new TranslateAnimation(Position_X.get(0), Position_X.get(7), Position_Y.get(0), Position_Y.get(7));
animation.setDuration(3000);
img_main[Start_Pos].startAnimation(animation);
The fromXDelta
and fromYDelta
in constructor of TranslateAnimation
are delta
from the original location of the view. I think your Position_X.get(0)
is an absolute position, not a delta
.
You can refer this link : Property Animation
Here you have the translation coordinate x,y vakues so this is simplest way you can translate view by,
yourView.animate().x(targetX).y(targetY).setDuration(2000);
Hope this helped!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.