I have two Activities A and B. I want to have the shrink Animation when Activity A calls B and maximize animation when Activity B calls A. I don't need the animation xml files for this.
When we call another Activity in Android it gives its default animation and then it calls shrink animation.
What I want is that the default animation should not occur and the animation that I want should occur.
Can we actually give the animation when calling another Activity?
Jelly Bean adds support for this with the ActivityOptions.makeCustomAnimation() method. Of course, since it's only on Jelly Bean, it's pretty much worthless for practical purposes.
Wrote a tutorial so that you can animate your activity's in and out,
Enjoy:
http://blog.blundellapps.com/animate-an-activity/
Since API 16 you can supply an activity options bundle when calling Context.startActivity(Intent, Bundle) or related methods. It is created via the ActivityOptions builder:
Don't forget to check out the other methods of the ActivityOptions builder and the ActivityOptionsCompat if you are using the Support Library.
API 5+:
For apps targeting API level 5+ there is the Activities
overridePendingTransition
method. It takes two resource IDs for the incoming and outgoing animations. An id of0
will disable the animations. Call this immediately after thestartActivity
call.i.e.:
API 3+:
You can prevent the default animation (Slide in from the right) with the
Intent.FLAG_ACTIVITY_NO_ANIMATION
flag in your intent.i.e.:
then in your Activity you simply have to specify your own animation.
This also works for the 1.5 API (Level 3).
You must use OverridePendingTransition method to achieve it, which is in the Activity class. Sample Animations in the apidemos example's res/anim folder. Check it. More than check the demo in ApiDemos/App/Activity/animation.
Example: