I have two activities Main and Temp. I am calling Activity Temp and applying the following animation getActivity().overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);

to get that Temp activity from right to left. Now i want to finish that Activity Temp with reverse animation.. Is that possible?

有帮助吗?

解决方案 2

yes its possible by giving

overridePendingTransition(enterAnim, exitAnim);

When you start the temp activity call this meathod giving enter and exit animation for that particular activity. Then that activity will only finish with an animation. If thats not working you can also call the overridePendingTransition in the onFinish(); of temp activity. So that while finishing it will end up with the animation you give.

其他提示

slide_in_left and slide_out_right exist in your default anim resources.

In your Main Activity, to open Temp (in your onClick):

finish();
Intent i2 = new Intent(Main.this, Temp.class);
startActivity(i2);
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);

In your Temp activity:

@Override
public void onBackPressed() {
    finish();
    Intent i2 = new Intent(Temp.this, Main.class);
    startActivity(i2);
    overridePendingTransition(android.R.anim.slide_in_left,
                    android.R.anim.slide_out_right);
    super.onBackPressed();
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top