Niranj Patel
Niranj Patel

Reputation: 33258

Zoom in Animation

I am using RotateAnimation for image. But I also want zoom on image with animation. Means when my image is rotate then image is also zooming...

How can I do zoom with rotate animation?

Upvotes: 6

Views: 19195

Answers (3)

Abhinav singh
Abhinav singh

Reputation: 1466

In the Zooming animation is called Scale Animation.

 ScaleAnimation scal=new ScaleAnimation(0, 1f, 0, 1f, Animation.RELATIVE_TO_SELF, (float)0.5,Animation.RELATIVE_TO_SELF, (float)0.5);
    scal.setDuration(500);
    scal.setFillAfter(true);
    ((ImageView)findViewById(R.id.logo)).setAnimation(scal);

Upvotes: 12

Komi
Komi

Reputation: 340

In anim xml, you can work with scale like this:

<scale
    android:pivotX="50%"
    android:pivotY="50%"
    android:fromXScale=".1"
    android:fromYScale=".1"
    android:toXScale="1.0"
    android:toYScale="1.0"
    android:duration="2000" />

Upvotes: 12

Pasha
Pasha

Reputation: 2425

I have one idea, hope it's help.

AnimationSet animSet = new AnimationSet(false);
RotateAnimation rotate = new RotateAnimation(0, 180);
ScaleAnimation zoom = new ScaleAnimation(0, 0, 1, 1);

animSet.addAnimation(rotate);
animSet.addAnimation(zoom);

animSet.start();

You should change parameters as need your application.

Upvotes: 8

Related Questions