1

When a button is pressed in my Activity, I want to finish the current Activity and start a new one. I want the new activity to be fixed in position, and revealed behind the outgoing activity as the old one slides off the screen.

Intent intent = new Intent(this, OverviewActivity.class);
startActivity(intent);
finish();
overridePendingTransition(R.anim.hold, R.anim.slide_out_top);

So for the new activity I'm applying a hold animation; this is a placeholder which doesn't animate anything. I have also tried passing 0instead of R.anim.hold but that doesn't work either.

<?xml version="1.0" encoding="utf-8"?>
<translate
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:fromXDelta="0"
  android:toXDelta="0"
  android:duration="@integer/slide_anim_duration" />

The new activity is being displayed immediately in its fixed location on top of the outgoing activity, so the sliding animation of the old activity is being obscured.

Is there any way I can make the new activity be drawn behind the old one, while the old one is animating off the screen?

Graham Borland
  • 60,055
  • 21
  • 138
  • 179

1 Answers1

0

Reordering the statements may work for you

      Intent intent = new Intent(this, OverviewActivity.class);
      overridePendingTransition(R.anim.hold, R.anim.slide_out_top);   
      startActivity(intent);
      finish();

You are overriding the transition when you have started your new activity and called finish() on the last one.

nobalG
  • 4,544
  • 3
  • 34
  • 72