Zoom In animation between Two Activities.

By | April 28, 2012

Hello everyone…

I have already shown you how to override default animation between activities.
Today I will show a zoom in and out animation between activities.

Take a look at this post for another animation between activities.

Create files named zoom_enter.xml and zoom_exit.xml in the res/anim folder.

zoom_enter.xml file contents.

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/decelerate_interpolator">
    <scale android:fromXScale="2.0" android:toXScale="1.0"
           android:fromYScale="2.0" android:toYScale="1.0"
           android:pivotX="50%p" android:pivotY="50%p"
           android:duration="@android:integer/config_mediumAnimTime" />
</set>

zoom_exit.xml file contents.

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/decelerate_interpolator"
        android:zAdjustment="top">
    <scale android:fromXScale="1.0" android:toXScale=".5"
           android:fromYScale="1.0" android:toYScale=".5"
           android:pivotX="50%p" android:pivotY="50%p"
           android:duration="@android:integer/config_mediumAnimTime" />
    <alpha android:fromAlpha="1.0" android:toAlpha="0"
            android:duration="@android:integer/config_mediumAnimTime"/>
</set>

Now replace this is in the previous post

overridePendingTransition(R.anim.fade, R.anim.hold);

with this code

overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);

Now run the application and you are done.
You will see a zoom in animation between the activities.
Refer this post for the rest of the code

2 thoughts on “Zoom In animation between Two Activities.

  1. Pingback: How to show a sliding window from below in Android? | Coderz Heaven

  2. Pingback: Use of custom animations in a FragmentTransaction when pushing and popping a stack. or How to apply animations in Fragments when pushing on to a stack? | Free Tools Successful Bloggers Are Using

Leave a Reply

Your email address will not be published. Required fields are marked *