Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

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

OP niranjan94

20th June 2013, 02:35 PM   |  #1  
niranjan94's Avatar
OP Senior Member
Flag Coimbatore
Thanks Meter: 483
 
209 posts
Join Date:Joined: Jun 2012
Donate to Me
More

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, 2123 views)
Last edited by niranjan94; 4th October 2013 at 03:29 PM.
The Following 70 Users Say Thank You to niranjan94 For This Useful Post: [ View ]
20th June 2013, 02:36 PM   |  #2  
niranjan94's Avatar
OP Senior Member
Flag Coimbatore
Thanks Meter: 483
 
209 posts
Join Date:Joined: Jun 2012
Donate to Me
More
Post Reserved for updates
Sorry... Reserved for updates
The Following 4 Users Say Thank You to niranjan94 For This Useful Post: [ View ]
20th June 2013, 07:19 PM   |  #3  
nikwen's Avatar
Recognized Contributor
Thanks Meter: 1,407
 
2,805 posts
Join Date:Joined: Feb 2013
More
And that is everything?! Cool.

Thanks.
The Following User Says Thank You to nikwen For This Useful Post: [ View ]
22nd June 2013, 09:47 AM   |  #4  
niranjan94's Avatar
OP Senior Member
Flag Coimbatore
Thanks Meter: 483
 
209 posts
Join Date:Joined: Jun 2012
Donate to Me
More
Angry
Quote:
Originally Posted by nikwen

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 ..
The Following 6 Users Say Thank You to niranjan94 For This Useful Post: [ View ]
2nd July 2013, 01:05 PM   |  #5  
Junior Member
Thanks Meter: 0
 
9 posts
Join Date:Joined: Feb 2013
Prompt
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
Last edited by erpejo96; 2nd July 2013 at 02:20 PM.
2nd July 2013, 02:43 PM   |  #6  
nikwen's Avatar
Recognized Contributor
Thanks Meter: 1,407
 
2,805 posts
Join Date:Joined: Feb 2013
More
Quote:
Originally Posted by erpejo96

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?
2nd July 2013, 06:00 PM   |  #7  
sak-venom1997's Avatar
Senior Member
Flag Lucknow
Thanks Meter: 409
 
921 posts
Join Date:Joined: Feb 2013
Donate to Me
More
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: [ View ]
4th July 2013, 11:11 AM   |  #8  
nikwen's Avatar
Recognized Contributor
Thanks Meter: 1,407
 
2,805 posts
Join Date:Joined: Feb 2013
More
Quote:
Originally Posted by nanospedy

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: [ View ]
4th July 2013, 06:18 PM   |  #9  
Senior Member
Thanks Meter: 31
 
99 posts
Join Date:Joined: Nov 2012
More
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
5th July 2013, 06:54 AM   |  #10  
@mne_gk's Avatar
Junior Member
Thanks Meter: 0
 
1 posts
Join Date:Joined: Mar 2013
Thanks really helpful! :thumbup:

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

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes