Aktivitätsnavigation: Benutzerdefinierte Animation mit popEnter und popExit wie Fragmente

Aktivitäten mit einer Animation können mit dem folgenden Code geändert werden:

Bundle animation = ActivityOptions.makeCustomAnimation(App.getContext(), R.anim.enter_from_right, R.anim.exit_to_left).toBundle();
startActivity(intent, animation);

Für Fragmente können Sie mit FragmentTransaction etwas Ähnliches tun:

// ...
transaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left);
// ...

Das funktioniert! Ich hätte aber gerne eine Animation beim Zurückdrücken (Pop from Backstack). Für Fragmente fügen Sie einfach 2 Animationsressourcen hinzu (popEnter & popExit):

transaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right);

Wie kann ich die gleiche "Back-Animation" für Aktivitäten erstellen?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage