Android: Flip Animation using XML for animation in android

18,554

Try this

overridePendingTransition(R.anim.grow_from_middle,R.anim.shrink_to_middle);

grow_from_middle.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale
        android:interpolator="@android:anim/linear_interpolator"
        android:fromXScale="0.0"
        android:toXScale="1.0"
        android:fromYScale="0.7"
        android:toYScale="1.0"
        android:fillAfter="false"
        android:startOffset="200"
        android:duration="200" />
    <translate
        android:fromXDelta="50%"
        android:toXDelta="0"
        android:startOffset="200"
        android:duration="200"/>
</set>

shrink_to_middle.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale
        android:interpolator="@android:anim/linear_interpolator"
        android:fromXScale="1.0"
        android:toXScale="0.0"
        android:fromYScale="1.0"
        android:toYScale="0.7"
        android:fillAfter="false"
        android:duration="200" />
    <translate
        android:fromXDelta="0"
        android:toXDelta="50%"
        android:duration="200"/>
</set>
Share:
18,554
Shreyash Mahajan
Author by

Shreyash Mahajan

About Me https://about.me/sbm_mahajan Email [email protected] [email protected] Mobile +919825056129 Skype sbm_mahajan

Updated on June 06, 2022

Comments

  • Shreyash Mahajan
    Shreyash Mahajan about 2 years

    For searching on net i found that there is ViewFlipper class that gives the Flip view animation between two view/ But for that should be in the same Activity. I also know that the Flip animation is not suported for the activity change. as right now android support only 2d animation during activity change.

    I want is the make the same effect for changing the activity.

    So is there any similar like xml animation that gives effect as like FLip View so i provide that to my activity change and get the Such Flip effect for the Activity change.

    Please provide me some xml for animation that gives the Flip type animation tht works for activity change.

    Thanks.

  • Shreyash Mahajan
    Shreyash Mahajan over 12 years
    Thanks blessenm for answer. Let me check it.
  • Shreyash Mahajan
    Shreyash Mahajan over 12 years
    where should i have to write this line: overridePendingTransition(R.anim.grow_from_middle,R.anim.shr‌​ink_to_middle);
  • Shreyash Mahajan
    Shreyash Mahajan over 12 years
    I have paste it after start activity but it tells me to crete methos with the same name.
  • blessanm86
    blessanm86 over 12 years
    The above code should work if you call after startactivity. The overidePandingTransisition should be available if you are starting the activity inside an activity. Otherwise you will need to use the context or something else.
  • Shreyash Mahajan
    Shreyash Mahajan over 12 years
    Ok. But i got that is its only aplicable for android 2.0 or above.
  • sky91
    sky91 over 9 years
  • iSofia
    iSofia about 7 years
    Works great! Thank you.