2

How to add transition effect for layouts in android when using intents.

from one layout to another.

vizzz
  • 37
  • 1
  • 1
  • 8
  • possible duplicate of [Transition effects and Intents](http://stackoverflow.com/questions/10507057/transition-effects-and-intents) – Matthieu Jan 04 '13 at 15:03

2 Answers2

7

If you want to add transition effects when you shift from one Activity to other, use the following code,

Intent i = new Intent(First.this, Second.class);
i.putExtra("data", data);
startActivity(i);

/** Fading Transition Effect */
First.this.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
Sahil Mahajan Mj
  • 12,721
  • 8
  • 55
  • 101
  • thanks for this, but where can download the anim fadein and fadeout? – jlopez Jan 04 '13 at 12:12
  • Thank you I have given you a upvote, I am using a code to switch between Activities fade-in fade-out that changes with transparency. I would like to be able to use an effect that move the screen to the right or left, is this possible? – jlopez Jan 04 '13 at 12:31
  • @Androiduser for this, you have to create your own animation xml file – Sahil Mahajan Mj Jan 04 '13 at 12:40
  • Thanks Sahil...do u knw hw to get a 3d flip effect in trasition..Is there any xml for that?? – vizzz Jan 07 '13 at 03:47
2

So for the animation use the code in OnCreate() of second activity as:

overridePendingTransition(R.anim.fadein, R.anim.fadeout);

Or

After intent

    First.this.overridePendingTransition(R.anim.fadein, R.anim.fadeout);

This will help you alot. Following links will help you:Animation

Animation2

Community
  • 1
  • 1
Manoj Fegde
  • 5,022
  • 14
  • 46
  • 92