I am in a situation where I want to have no visible animation during a transition between Activities. I am currently doing the following:
startActivity( intent );
getActivity().overridePendingTransition( 0, 0 );
Works fine. Once in the second Activity, I want to animate LayoutTransitions (for better or for worse) -- specifically, calling addView()
on the root view coupled with android:animateLayoutChanges="true"
in XML.
Right now, addView()
is being called in my onResume()
of the second Activity and shows no LayoutTransition animations (just pops the added view in place). I'm guessing that either overridePendingTransitions(int, int)
or startActivity()
(and thus the override as well) are "in effect" until some specified lifecycle event occurs in the second Activity. But I can't find this information. Should I just assume that it's until the end of onResume()
?
Removing a View later, say when the user presses the back button, triggers the LayoutTransition animation fine. But this is unrelated to the Activity lifecycle.
So my question is, at what point does overridePendingTransition( 0, 0 )
release control of animations?
Release of overridePendingTransition
is not associated with any lifecycle event.
overridePendingTransition
will release control after the duration of animation is completed.
That is, 300 ms
(default duration) or user specified duration
(set in XML or using setDuration())
For no visible animation during a transition between Activities, use FLAG_ACTIVITY_NO_ANIMATION
instead of overridePendingTransition
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity( intent );