Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,733,293 Members 38,570 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE][RES] Android Animation XML resources for Activity Transition

Tip us?
 
niranjan94
Old
(Last edited by niranjan94; 4th October 2013 at 02:29 PM.)
#1  
niranjan94's Avatar
Senior Member - OP
Thanks Meter 467
Posts: 209
Join Date: Jun 2012
Location: Coimbatore

 
DONATE TO ME
Info 2 [GUIDE][RES] Android Animation XML resources for Activity Transition


Quote:
FEATURED IN XDA NEWS ! App Animation XMLs Made Easy

When i was making my first app, I wanted to add some Transitions for my Activities. But didn't know how to make the anim xml files. So , I searched Google Got some pretty simple animations that would be useful for any app developer.

appear.xml - make an it just *appear*
 
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <alpha
		android:interpolator="@android:anim/accelerate_interpolator"
        android:duration="1"
           android:fromAlpha="1.0"
           android:toAlpha="1.0"/>
</set>

fadein.xml - make it slowly fade into view

 
HTML Code:
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
	<alpha
    	android:fromAlpha="0.0"
    	android:toAlpha="1.0"
    	android:interpolator="@android:anim/accelerate_interpolator" 
		android:duration="300"
		android:repeatCount="0" />
</set>

fadeout.xml - make it slowly fade out of view

 
HTML Code:
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
	<alpha
    	android:fromAlpha="1.0"
    	android:toAlpha="0.0"
    	android:interpolator="@android:anim/accelerate_interpolator" 
		android:duration="300"
		android:repeatCount="0" />
</set>

push_down_in.xml

 
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromYDelta="-100%p" android:toYDelta="0" android:duration="400"/>
</set>

push_down_out.xml

 
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromYDelta="0" android:toYDelta="100%p" android:duration="400"/>
</set>

push_right_in.xml

 
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
	<translate android:fromXDelta="-100%p" android:toXDelta="0" android:duration="300"/>
	<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" />
</set>

push_left_in.xml

 
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
	<translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="300"/>
	<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" />
</set>

push_left_out.xml

 
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
	<translate android:fromXDelta="0" android:toXDelta="-100%p" android:duration="300"/>
	<alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="300" />
</set>

push_right_out.xml

 
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
	<translate android:fromXDelta="0" android:toXDelta="100%p" android:duration="300"/>
	<alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="300" />
</set>

push_up_in.xml

 
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromYDelta="100%p" android:toYDelta="0" android:duration="300"/>
    <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" />
</set>

push_up_out.xml

 
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromYDelta="0" android:toYDelta="-100%p" android:duration="300"/>
    <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="300" />
</set>

rotation.xml

 
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<rotate
 xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0"
    android:toDegrees="-90"
    android:pivotX="50%"
    android:pivotY="50%"
    android:duration="0" android:fillAfter="true">
</rotate>

scale_towards_corner.xml

 
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale android:fromYScale="1.0" android:toYScale="0"
        android:fromXScale="1.0" android:toXScale="0" 
        android:duration="500"/>
</set>

scale_from_corner.xml

 
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale android:fromYScale="0" android:toYScale="1.0"
        android:fromXScale="0" android:toXScale="1.0" 
        android:duration="500" android:pivotX="100%"
        android:pivotY="100%" />
</set>

shrink_and_rotate_a.xml [exit]

 
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
    android:fromXScale="1.0" android:toXScale="0.8"
    android:fromYScale="1.0" android:toYScale="0.8"
    android:pivotX="50%p" android:pivotY="50%p"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:duration="100"
/>
<scale
    android:fromXScale="1.0" android:toXScale="0.0"
    android:fromYScale="1.0" android:toYScale="1.0"
    android:pivotX="50%p" android:pivotY="50%p"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:duration="150"
    android:startOffset="100"
/>

shrink_and_rotate_b.xml [entrance]

 
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
    android:fromXScale="0.0" android:toXScale="1.0"
    android:fromYScale="1.0" android:toYScale="1.0"
    android:pivotX="50%p" android:pivotY="50%p"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:duration="150"
    android:startOffset="250"
/>

<scale
    android:fromXScale="0.8" android:toXScale="1.0"
    android:fromYScale="0.8" android:toYScale="1.0"
    android:pivotX="50%p" android:pivotY="50%p"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:duration="100"
    android:startOffset="400"
/>


To modify the speed of the animation you can edit the android:duration parameter (in milliseconds).

USAGE:

Using an Animation file is simple :
  1. Just place the required xml files inside res/anim/ folder.
  2. And call the required animation by using R.anim.animation_name
  3. For example, to add a transition while calling an activity, You can use overridePendingTransition(R.anim.fadein,R.anim.fad eout);

DOWNLOADING THE ANIMATION RESOURCES:

You can either manually copy the required xml file's content from above (or) You can also download the entire package that i have attached along with this thread. (or) You can click this link and download it.

More animations will be added in future !

Attached Files
File Type: zip anim.zip - [Click for QR Code] (5.3 KB, 1573 views)
 

Galaxy Tab 2 10.1"
ROM: CyanogenMod 11 Nightly (Android 4.4.2)
KERNEL: 3.0.31

HTC Explorer aka Pico
ROM: CM11 (Android 4.4.2)
KERNEL: 3.0.16

Nokia Lumia 510
Software: Windows Phone 7.5
OSv: 7.10


Current Projects

Kovai Deals(website) | Aero Droid(app) |ShowJava - APK to Java Decompiler(app)| AID(app) | Follow me on GitHub, Facebook, Twitter , 500px !




_
_
The Following 65 Users Say Thank You to niranjan94 For This Useful Post: [ Click to Expand ]
 
niranjan94
Old
#2  
niranjan94's Avatar
Senior Member - OP
Thanks Meter 467
Posts: 209
Join Date: Jun 2012
Location: Coimbatore

 
DONATE TO ME
Post Reserved for updates

Sorry... Reserved for updates
The Following 4 Users Say Thank You to niranjan94 For This Useful Post: [ Click to Expand ]
 
niranjan94
Old
#4  
niranjan94's Avatar
Senior Member - OP
Thanks Meter 467
Posts: 209
Join Date: Jun 2012
Location: Coimbatore

 
DONATE TO ME
Quote:
Originally Posted by nikwen View Post
And that is everything?! Cool.

Thanks.
I'll be adding more such animations in future ... along with a small guide for ACtivity Transitions, Dialog animations , and small UI animations etc ..
 

Galaxy Tab 2 10.1"
ROM: CyanogenMod 11 Nightly (Android 4.4.2)
KERNEL: 3.0.31

HTC Explorer aka Pico
ROM: CM11 (Android 4.4.2)
KERNEL: 3.0.16

Nokia Lumia 510
Software: Windows Phone 7.5
OSv: 7.10


Current Projects

Kovai Deals(website) | Aero Droid(app) |ShowJava - APK to Java Decompiler(app)| AID(app) | Follow me on GitHub, Facebook, Twitter , 500px !




_
_
The Following 6 Users Say Thank You to niranjan94 For This Useful Post: [ Click to Expand ]
 
erpejo96
Old
(Last edited by erpejo96; 2nd July 2013 at 01:20 PM.)
#5  
Junior Member
Thanks Meter 0
Posts: 2
Join Date: Feb 2013
Beautiful guide
I would like to make screen rotate when I rotate my device, showing the rotation animation. Should I put a file with "rotation.xml" codes into /system/framework/framework-res.apk/res/anim ?

My device is a Samsung Galaxy Ace-i (gt-s5830i) with Gingerbread 2.3.6

thanks for replies
 
nikwen
Old
#6  
nikwen's Avatar
Recognized Contributor
Thanks Meter 1295
Posts: 2,690
Join Date: Feb 2013
Quote:
Originally Posted by erpejo96 View Post
Beautiful guide
I would like to make screen rotate when I rotate my device, showing the rotation animation. Should I put a file with "rotation.xml" codes into /system/framework/framework-res.apk/res/anim ?

My device is a Samsung Galaxy Ace-i (gt-s5830i) with Gingerbread 2.3.6

thanks for replies
App development (which this guide is for) is very different to ROM modifications. I think that it will not work. However, it would be worth a try.

Why don't you ask your favourite ROM developer to add this to his ROM?
 
sak-venom1997
Old
#7  
sak-venom1997's Avatar
Senior Member
Thanks Meter 403
Posts: 919
Join Date: Feb 2013
Location: Lucknow

 
DONATE TO ME
Nice work keep it up

Sent from my GT-S5302 using Tapatalk 2
The Following User Says Thank You to sak-venom1997 For This Useful Post: [ Click to Expand ]
 
nikwen
Old
#8  
nikwen's Avatar
Recognized Contributor
Thanks Meter 1295
Posts: 2,690
Join Date: Feb 2013
Quote:
Originally Posted by nanospedy View Post
Tanks forme sharing
Please do not get your first 10 posts for posting in the dev section just by posting messages which all are only "thanks".
The Following User Says Thank You to nikwen For This Useful Post: [ Click to Expand ]
 
out of ideas
Old
#9  
Senior Member
Thanks Meter 31
Posts: 99
Join Date: Nov 2012
cool thread, thanks.

do you know off-hand how many are compatible with api10?

I was trying to get Card flip working, but objectanimator is only for 11+

http://developer.android.com/trainin.../cardflip.html <--card flip
 
@mne_gk
Old
#10  
@mne_gk's Avatar
Junior Member
Thanks Meter 0
Posts: 1
Join Date: Mar 2013
Thanks really helpful! :thumbup:

Sent from my GT-I9300 using xda app-developers app

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes