Android Programming Mobile

Android Activity transition slide in/out animation

This is a very common effect, however the Android framework only provides the slide in animation. This is how I implement all the sliding transition animation. There’s in total 4 XMLs to define the animation, and with the use of overridePendingTransition() in appropriate location you can implement this easily.







When starting new Activity

add overridePendingTransition right after you call startActivity

When Back to previous Activity

When the user click back button, you will have to play the reserve animation to go back to previous Activity, you can do so by overriding the
onBackPressed method

<!– Crayon Syntax Highlighter v_2.7 losartan dosage.2_beta –>

Update 3 July 2015:

You can go to this GitHub repo to download the 4 xml files. I may add more animations there, make sure to star it!


16 replies on “Android Activity transition slide in/out animation”

Thanks. Here is my transition:

overridePendingTransition(R.anim.pull_in_right, R.anim.push_out_left);

overridePendingTransition(R.anim.pull_in_left, R.anim.push_out_right);

Share your thoughts