ユーザーがボタンをタップすると、アニメーションを通じて新しいアクティビティに移動するアプリがあります。押し戻された前のアクティビティは、アニメーション (トランジション イン/アウト) を使用して再度作成されます。これを高速に実行すると、エラーが発生します。
コード:
startActivity(intent);
overridePendingTransition(R.anim.slide_in,R.anim.slide_out);
finish();
エラー :
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:3339)
at android.view.ViewGroup.addView(ViewGroup.java:3210)
at android.widget.ViewAnimator.addView(ViewAnimator.java:184)
at android.view.ViewGroup.addView(ViewGroup.java:3155)
at android.view.ViewGroup.addView(ViewGroup.java:3131)
at com.myapps.tryanim.w.onAnimationEnd(Unknown Source)
at android.view.animation.AnimationSet.getTransformation(AnimationSet.java:400)
at android.view.animation.Animation.getTransformation(Animation.java:940)
at android.view.View.drawAnimation(View.java:13200)
at android.view.View.draw(View.java:13339)
at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
at android.view.View.draw(View.java:13710)
at android.view.View.getDisplayList(View.java:12645)
at android.view.View.getDisplayList(View.java:12689)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2910)
at android.view.View.getDisplayList(View.java:12583)
at android.view.View.getDisplayList(View.java:12689)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2910)
at android.view.View.getDisplayList(View.java:12583)
at android.view.View.getDisplayList(View.java:12689)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2910)
at android.view.View.getDisplayList(View.java:12583)
at android.view.View.getDisplayList(View.java:12689)
at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1198)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2173)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2045)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1854)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
at android.view.Choreographer.doCallbacks(Choreographer.java:562)
at android.view.Choreographer.doFrame(Choreographer.java:532)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
ここで何が問題になる可能性があります。
slide_in xml-anim
<translate
android:fromXDelta="100%"
android:toXDelta="0%"
android:duration="800" />
slide_out xml
<translate
android:fromXDelta="0%"
android:toXDelta="-100%"
android:duration="800" />