Animations In Android KitKat

With the introduction of Android KitKat, Google has brought a number of new additions to Android.

In this tutorial I will focus on one of those additions i.e. transition framework.

Time by time with the new versions of android it brings new improved animation tools for developers. Animations Added in Honeycomb come with very good and easy API for creating animations. Whereas in KitKat, android.transition provides fantastic ways to define and declare animations in an  easy way.

Let’s first see what is a scene and what is a transition. One way to define a scene is by loading it from a layout file:

 

 

 

A scene defines a given state of the UI, whereas a transition defines the change from one scene to another.

Once you have defined a scene the simplest way to perform a transition is to let the TransitionManager perform a default one:

 

 

 

I will be writing a simple code below to explain you this all in more detail. Follow the steps below

Step1: Create a new android project in your android IDE. Write below code into main activity file:

 

 

 

Step2:  Create an xml named scene1 and write following code in it:

 

 

 

 Step3: Create and write following into scene2.xml:

 

 

 

 Step4:  Create and write following into transition/transitionmanager.xml:

 

 

 

 

Step5: Create and write following into transition/slowtransition.xml:

 

 

 

 

Step6: Create a new fragment activity and write following into it:

 

 

 

 Step7: Write the following into your main activity:

 

 

 

 Step8: Run for the output

animation1

animation2

Thats it.  

Leave a Comment: