-1

I have a click button on first activity and when we click on that button then I want to animate second activity but in my case my first activity also animated with second here is code

 Intent createCompaignActivityIntent = new Intent(mActivity, CreateCompaignActivity.class);
 mActivity.startActivity(createCompaignActivityIntent);
 mActivity.overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );

slide_in_up.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromYDelta="100%p" android:toYDelta="0%p"
    android:duration="@android:integer/config_longAnimTime"/>

slide_out_up.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromYDelta="0%p" android:toYDelta="-100%p"
    android:duration="@android:integer/config_longAnimTime"/>
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

1 Answers1

1

If you don't want to animate your first Activity, then change android:toYDelta="-100%p" to android:toYDelta="0%p" in your slide_out_up.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromYDelta="0%p" android:toYDelta="0%p"
    android:duration="@android:integer/config_longAnimTime"/>

Edit:

To achieve slide down on exit of second activity, create a animation file and copy below code

slide_out_down.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromYDelta="0%p" android:toYDelta="100%p"
    android:duration="@android:integer/config_longAnimTime"/>

and in your second activity's onBackPressed() add the below code.

@Override
public void onBackPressed() {
    super.onBackPressed();
    overridePendingTransition(R.anim.slide_out_up, R.anim.slide_out_down);
}
Suresh Kumar
  • 2,014
  • 3
  • 19
  • 32