seema
seema

Reputation: 75

how to zoom in and zoom out animation to the image in android

I am developing an app with zoom animation in android. like in button onclick event go to the next activity, on that activity i have an image that image should be zoom in with animation. if anybody come across this help me.

Upvotes: 2

Views: 9404

Answers (2)

user2315370
user2315370

Reputation:

use this code in your next Activity onCreate() method

ImageView imageView = (ImageView)findViewById(R.id.imageView);
        
Animation animZoomin = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.zoom_in);
        
imageView.startAnimation(animZoomin);

Create an xml file which defines type of animation to perform. This file should be located under anim folder under res directory (res ⇒ anim ⇒ zoom_in.xml). If you don’t have anim folder in your res directory create one.

put following code in zoom_in.xml file

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true" >
 
    <scale
        android:duration="1000"
        android:fromXScale="1"
        android:fromYScale="1"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="3"
        android:toYScale="3"/>
</set>

Upvotes: 5

frogoscar
frogoscar

Reputation: 125

There seem to be some topics on StackOverFlow similar :

zoom in and zoom out animation in android

Zoom in Animation

And here is a article on developer.android.com :

http://developer.android.com/training/animation/zoom.html

Hope that helps. :]

Upvotes: 0

Related Questions