Skip to content Skip to sidebar Skip to footer

Android Image View Scale Animation

hi im wanting to know how to scale animate a logo and move its position? i have an if statement that runs some checks and then when its done i want it to scale down an image view

Solution 1:

You can do that by applying ScaleAnimation and TranslateAnimation together in AnimationSet

// Scaling
Animation scale = new ScaleAnimation(fromXscale, toXscale, fromYscale, toYscale, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
// 1 second duration
scale.setDuration(1000);
// Moving up
Animation slideUp = new TranslateAnimation(fromX, toX, fromY, toY);
// 1 second duration
slideUp.setDuration(1000);
// Animation set to join both scaling and moving
AnimationSet animSet = new AnimationSet(true);
animSet.setFillEnabled(true);
animSet.addAnimation(scale);
animSet.addAnimation(slideUp);
// Launching animation set
logo.startAnimation(animSet);

Post a Comment for "Android Image View Scale Animation"