Ich entwickle eine Chat-App und habe Probleme herauszufinden, wie man den Übergang zwischen zwei Aktivitäten richtig animieren kann. Ich habe das schon seit einiger Zeit gegoogelt und habe SO auch danach gesucht, aber tut mir leid im Voraus, wenn diese Frage schon beantwortet wurde.Animation zwischen Aktivitäten, von denen eine singleTask ist
Ich habe eine ChatMainActivity
, die ein Fragment enthält eine Liste von Chats und eine ChatContentFragmentActivity
enthält, die ein Fragment enthält die Chat-Nachrichten enthält. Wie unten zu sehen, habe ich die ChatMainActivity in meiner AndroidManifest.xml als launchMode="singleTask"
deklariert.
<activity
android:name=".ui.activities.ChatMainActivity"
android:launchMode="singleTask"
android:theme="@style/AppTheme"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".ui.activities.ChatContentFragmentActivity"
android:parentActivityName=".ui.activities.ChatMainActivity"
android:theme="@style/AppTheme"
android:windowSoftInputMode="adjustResize" />
Das sind meine Animation .xmls:
chat_content_activity_enter_animation.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@integer/activity_animation_duration"
android:fromXDelta="100%"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="0" />
</set>
chat_content_activity_exit_animation.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@integer/activity_animation_duration"
android:fromXDelta="0"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="100%" />
</set>
chat_list_activity_enter_animation.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@integer/activity_animation_duration"
android:fromXDelta="-100%"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="0" />
</set>
chat_list_activity_exit_animation.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@integer/activity_animation_duration"
android:fromXDelta="0"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="-100%" />
</set>
Und hier ist, wie ich sie verwenden:
Im Adapter
der RecyclerView
enthält, die Chats in ChatMainActivity
Intent intent = new Intent(context, ChatContentFragmentActivity.class);
context.startActivity(intent);
activity.overridePendingTransition(R.anim.chat_content_activity_enter_animation, R.anim.chat_list_activity_exit_animation);
ChatContentFragmentActivity
@Override
public void finish() {
super.finish();
overridePendingTransition(R.anim.chat_content_activity_exit_animation, R.anim.chat_list_activity_enter_animation);
}
Mein Problem ist jetzt, dass die Eingabe- und Exit-Animationen der ChatContentFragmentActivity
angezeigt werden, aber die ChatMainActivity
tut nichts.
Es gab eine SO-Frage, die ich jetzt anscheinend nicht finden kann, die suggerierte, dass singleTask hier ein Problem war, aber ich erinnere mich, dass die Lösung in dieser Frage mir nicht hilft.
Kann jemand wissen, wie ich den Ausgang erhalten und Animation meiner ChatMainActivity
spielen kann?
Edit: Dies ist, wie es im Moment aussieht:
@sushildlh meine bearbeiten f sehen oder ein .gif zeigt, wie es im Moment funktioniert (falsch) – HePa
benutze diesen Link http://www.christianpeeters.com/android-tutorials/tutorial-activity-slide-animation/#more-483 und verbessere dein Knowleadge auch ... viel Spaß beim Codieren – sushildlh
Ich habe versucht, was sie in diesem Tutorial gemacht haben, aber es hat leider nicht geholfen und hat die gleichen Ergebnisse wie im '.gif' ergeben. – HePa