Android 3d animation like Google Now Launcher Menu Animation -
i need make animation between activities or fragments this. use android api >=14.
http://www.youtube.com/watch?v=cnmqiv5ocnk - it's nexus5 launcher
i`ve tried animation android objectanimator, wasn't similar video animation.
thanks in advance.
i`ve tried code
(gla_on.xml):
<objectanimator android:duration="0" android:propertyname="alpha" android:valuefrom="1.0" android:valueto="0.0" /> <objectanimator android:duration="1000" android:interpolator="@android:interpolator/accelerate_decelerate" android:propertyname="scaley" android:valuefrom="1" android:valueto="12" /> <objectanimator android:duration="1000" android:interpolator="@android:interpolator/accelerate_decelerate" android:propertyname="scalex" android:valuefrom="1" android:valueto="12" />
gla_off.xml:
<objectanimator android:duration="0" android:propertyname="alpha" android:valuefrom="0.0" android:valueto="1.0" /> <objectanimator android:duration="1000" android:interpolator="@android:interpolator/accelerate_decelerate" android:propertyname="scaley" android:valuefrom="1" android:valueto="12" /> <objectanimator android:duration="1000" android:interpolator="@android:interpolator/accelerate_decelerate" android:propertyname="scalex" android:valuefrom="1" android:valueto="12" />
and put fragment of code:
getfragmentmanager() .begintransaction() .setcustomanimations(r.anim.gla_on, r.anim.gla_off) .replace(r.id.container, new nextfragment()) .addtobackstack(null) .commit();
but nextfragment doesn't show
closed
after many attempts found decision.
(you can watch result here - http://www.youtube.com/watch?v=npn0c68okys )
i create 4 animations in android resource folder anim
gla_there_come.xml
<set xmlns:android="http://schemas.android.com/apk/res/android" > <objectanimator android:duration="500" android:propertyname="alpha" android:valuefrom="0.0" android:valueto="1.0" /> <objectanimator android:duration="500" android:interpolator="@android:interpolator/accelerate_decelerate" android:propertyname="scaley" android:valuefrom="0" android:valueto="1" /> <objectanimator android:duration="500" android:interpolator="@android:interpolator/accelerate_decelerate" android:propertyname="scalex" android:valuefrom="0" android:valueto="1" /> </set>
gla_there_gone.xml
<set xmlns:android="http://schemas.android.com/apk/res/android" > <objectanimator android:duration="500" android:propertyname="alpha" android:valuefrom="1.0" android:valueto="0.0" /> <objectanimator android:duration="500" android:interpolator="@android:interpolator/accelerate_decelerate" android:propertyname="scaley" android:valuefrom="1" android:valueto="12" /> <objectanimator android:duration="500" android:interpolator="@android:interpolator/accelerate_decelerate" android:propertyname="scalex" android:valuefrom="1" android:valueto="12" /> </set>
gla_back_gone.xml
<set xmlns:android="http://schemas.android.com/apk/res/android" > <objectanimator android:duration="500" android:propertyname="alpha" android:valuefrom="0.0" android:valueto="1.0" /> <objectanimator android:duration="500" android:interpolator="@android:interpolator/accelerate_decelerate" android:propertyname="scaley" android:valuefrom="12" android:valueto="1" /> <objectanimator android:duration="500" android:interpolator="@android:interpolator/accelerate_decelerate" android:propertyname="scalex" android:valuefrom="12" android:valueto="1" /> </set>
gla_back_come.xml
<set xmlns:android="http://schemas.android.com/apk/res/android" > <objectanimator android:duration="500" android:propertyname="alpha" android:valuefrom="1.0" android:valueto="0.0" /> <objectanimator android:duration="500" android:interpolator="@android:interpolator/accelerate_decelerate" android:propertyname="scaley" android:valuefrom="1" android:valueto="0" /> <objectanimator android:duration="500" android:interpolator="@android:interpolator/accelerate_decelerate" android:propertyname="scalex" android:valuefrom="1" android:valueto="0" /> </set>
and added the code below fragmentactivity:
public void gotonext() { mshowingnext = true; getfragmentmanager() .begintransaction() .setcustomanimations(r.anim.gla_there_come, r.anim.gla_there_gone) .replace(r.id.container, new nextfragment()) .commit(); } public void goback() { mshowingnext = false; getfragmentmanager() .begintransaction() .setcustomanimations(r.anim.gla_back_gone, r.anim.gla_back_come) .replace(r.id.container, new mainfragment()) .commit(); }
Comments
Post a Comment