O'Reilly logo

Android 3.0 Animations by Alex Shaw

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing the SlideAndScale animation in Java

In Java, we instantiate the AnimationSet, ScaleAnimation, and TranslateAnimation. The animation objects are parameterized in their respective constructors.

We then add the ScaleAnimation and TranslateAnimation to the AnimationSet.

AnimationSet slideAndScale = new AnimationSet(true);
TranslateAnimation slide = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 1f,
Animation.RELATIVE_TO_PARENT, 0,
Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0
);
ScaleAnimation scale = new ScaleAnimation(
10,
1,
10,
1
);
slideAndScale.addAnimation(slide);
slideAndScale.addAnimation(scale);
slideAndScale.setDuration(1000);

Writing the SlideAndScale animation In XML

In XML, the tween animation is created ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required