Animate Image Icon From Touch Place To Right-top Corner?
I am working on Android onlineShopping application.I have to apply some animation. cart image is displays on Right-top corner of the screen. List of items are on screen each item
Solution 1:
ultimately you want to move a view from one position to another position with animation.
Step 1: get initial position of that view
int fromLoc[] = newint[2];
v.getLocationOnScreen(fromLoc);
float startX = fromLoc[0];
float startY = fromLoc[1];
Step 2: get destination position
int toLoc[] = newint[2];
desti.getLocationOnScreen(toLoc);
float destX = toLoc[0];
float destY = toLoc[1];
Step 3: create a class to manage animation
publicclassAnimations {
public Animation fromAtoB(float fromX, float fromY, float toX, float toY, AnimationListener l, int speed){
AnimationfromAtoB=newTranslateAnimation(
Animation.ABSOLUTE, //from xType
fromX,
Animation.ABSOLUTE, //to xType
toX,
Animation.ABSOLUTE, //from yType
fromY,
Animation.ABSOLUTE, //to yType
toY
);
fromAtoB.setDuration(speed);
fromAtoB.setInterpolator(newAnticipateOvershootInterpolator(1.0f));
if(l != null)
fromAtoB.setAnimationListener(l);
return fromAtoB;
}
}
Step 4: add animationlistener and start animation on desired view
AnimationListener animL = newAnimationListener() {
@OverridepublicvoidonAnimationStart(Animation animation) {
}
@OverridepublicvoidonAnimationRepeat(Animation animation) {
}
@OverridepublicvoidonAnimationEnd(Animation animation) {
//this is just a method call you can create to delete the animated view or hide it until you need it again.clearAnimation();
}
};
//now start animation as mentioned below:
Animationsanim=newAnimations();
Animationa= anim.fromAtoB(startX, startY, destX, destY, animL,850);
v.setAnimation(a);
a.startNow();
I hope it will be helpful !!
Solution 2:
Solution 3:
check this example hope this will help u: http://developer.android.com/training/animation/zoom.html
Post a Comment for "Animate Image Icon From Touch Place To Right-top Corner?"