Edit
Issue can be seen here:
I have a login screen and a registration screen.
When the user clicks the registration button - I would like to slide from the login screen to the registration screen. I have this working okay.
When the user presses the back button on the registration screen, I would like to slide back to the login screen.
This appears to be working, but the login screen activity is loading in the old activity before the animation has completed.
LoginActivity.java
public void createAccount(View view) {
Log.d(TAG, "Create Account clicked");
Intent intent = new Intent(getApplicationContext(), SignupActivity.class);
startActivityForResult(intent, REQUEST_SIGNUP);
overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
}
RegisterActivity.java
@Override
public void onBackPressed() {
super.onBackPressed();
Log.d(TAG, "Back clicked - return to login");
finish();
overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
}
push_left_in.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="500"
android:fromXDelta="100%p"
android:toXDelta="0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"/>
</set>
push_left_out.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="500"
android:fromXDelta="0"
android:toXDelta="-100%p"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"/>
</set>
push_right_in.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="500"
android:fromXDelta="0"
android:toXDelta="100%p"
android:interpolator="@android:anim/accelerate_decelerate_interpolator" />
</set>
push_right_out.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="500"
android:fromXDelta="-100%p"
android:toXDelta="0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator" />
</set>
Note
I have tried both the solutions below and neither works in my case.