Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
let Android Activity's transition animation like iOS navigationController's push-pop one
1.Override CommonActivity's startActivity and finish
@Override
public void startActivity(Intent intent) {
super.startActivity(intent);
overridePendingTransition(R.anim.from_right_in, R.anim.from_left_out);
}
@Override
public void finish() {
super.finish();
overridePendingTransition(R.anim.from_left_in, R.anim.from_right_out);
}
2.from_left_in.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="-100%p"
android:toXDelta="0"
android:duration="300"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" />
</set>
3.from_right_in.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="100%p"
android:toXDelta="0" android:interpolator="@android:interpolator/accelerate_decelerate"
android:duration="300"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" />
</set>
4.from_left_out.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0"
android:toXDelta="-100%p"
android:duration="300"/>
<alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="300" />
</set>
5.from_right_out.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0"
android:toXDelta="100%p"
android:duration="300"/>
<alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="300" />
</set>
@johncodeos

This comment has been minimized.

Copy link

johncodeos commented Dec 18, 2018

Beautiful transition! Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.