Android gridview expand element animation

Start new Activity and give overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);
where zoom_enter.xml has

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android=""
<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" />

and zoom_exit has

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android=""
<scale android:fromXScale="1.0" android:toXScale="2.0"
       android:fromYScale="1.0" android:toYScale="2.0"
       android:pivotX="50%p" android:pivotY="50%p"
       android:duration="@android:integer/config_mediumAnimTime" />
<alpha android:fromAlpha="1.0" android:toAlpha="0"

keep both of these file in /res/anim/ folder.

That’s called Shared Element Activity Transition.


Note that the shared element transitions require Android 5.0 (API level 21) and above.
You need to do is to provide a transition name that both Activites can use to create a transition animation with.
To use the shared transition name you need to provide the start intent with a option Bundle like this:

Intent intent = new Intent(this, DetailsActivity.class);
// Pass data object in the bundle and populate details activity.
intent.putExtra(DetailsActivity.EXTRA_CONTACT, contact);
ActivityOptionsCompat options = ActivityOptionsCompat.
    makeSceneTransitionAnimation(this, (View)ivProfile, "profile");
startActivity(intent, options.toBundle());

Here is step by step tutorial given for the same –
and for Fragments here at

Leave a Comment