How to put rotate animation between two activities.when is startactivity and next activity is start with rotate animation
Here's a tutorial on how to add an animation when transistioning between two activities. However, instead of using a translate animation like in the article, you'll want to use a rotate animation. For more information on animations, checkout this documentation.
Putting those two things together, here's what you need to do. First, where you make the call to start the new activity do this:
//Calls a new Activity
startActivity(new Intent(this, NewActivity.class));
//Set the transition -> method available from Android 2.0 and beyond
overridePendingTransition(R.anim.rotate_out,R.anim.rotate_in);
Then create the following two animations in your xml:
rotate_out.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" />
<rotate android:fromDegrees="0" android:toDegrees="90" android:pivotX="25%" />
</set>
rotate_in.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" />
<rotate android:fromDegrees="90" android:toDegrees="0" android:pivotX="-25%" />
</set>
You can play with the fromDegrees, toDegrees, and pivotX values to get exactly what you'd like.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With