Enter and exit animations do not display when Activity jumps

The effect I achieved is to enter from bottom to top and exit from top to bottom, but the exit effect is always not displayed at the beginning, the following is my code and solution
The slide_bottom_in.xml layout is the animation effect when entering:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:fromYDelta="100%"
        android:toYDelta="0"
        android:duration="500"/>
    <alpha
        android:fromAlpha="0.0"
        android:toAlpha="1.0"
        android:duration="500"/>
</set>

The slide_bottom_out.xml layout is the animation effect on exit:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:fromYDelta="0"
        android:toYDelta="100%"
        android:duration="500"/>
    <alpha
        android:fromAlpha="1.0"
        android:toAlpha="0.0"
        android:duration="500"/>

</set>

Do the following in the place where the Activity jumps:
Intent intent=new Intent(this, SelectBankCardActivity.class);
                startActivity(intent);
                overridePendingTransition(R.anim.slide_bottom_in,R.anim.slide_bottom_out);

Run the program and find that only the animation effect when entering is realized, but not when exiting.
Later found a solution:

Make the following modifications in the place where the Activity jumps:
Intent intent=new Intent(this, SelectBankCardActivity.class);
                startActivity(intent);
                overridePendingTransition(R.anim.slide_bottom_in,0);

In the place where the Activity exits, that is, the finish operation and the place where the return key is pressed, perform the following operations

                 finish();
                overridePendingTransition(0,R.anim.slide_bottom_out);
This solves the problem

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326343993&siteId=291194637