John
John

Reputation: 7880

Set new Activity to be below current one

I am creating a custom transition animation between two activities. By default, the new Activity is above the current one.

Is it possible to make the new Activity to be below current Activity? And if it is possible, then How to implement this?

Upvotes: 2

Views: 1389

Answers (2)

Android
Android

Reputation: 1272

Not sure if this is the best practice but try this:

In old activity:

Intent newActivity = new Intent(this, NewActivity.class);
startActivity(newActivity);

Then in your new Activity:

protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.new_activity);
    Intent oldActivity= new Intent(this, OldActivity.class);
    oldActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_SINGLE_TOP);
    startActivity(oldActivity);
}

Upvotes: 2

Rajesh Mikkilineni
Rajesh Mikkilineni

Reputation: 844

No that is not possible you can use Fragments to do so.. convert those Activities to Fragments and create a Activity and place those Fragments in Activity.

Ref :

http://developer.android.com/reference/android/app/Fragment.html http://developer.android.com/guide/components/fragments.html

Upvotes: 0

Related Questions