android animation Tween animation can perform only four small transitions like rotate, scale, transparency, and movement.) In 1 file you can define only single root, but if you want to define multiple animations in 1 file then you can use set. Inside set you can define multiple animations according to your need. android animation file will be created at <span style="color: #339966;">**res/anim/**</span> directory of your project. File name would be anything.

Below are tags:

1.  **<alpha>** for transparency
2.  **<scale>** for increase decrease size
3.  **<rotate>** for rotation
4.  **<translate>** for movement.
5.  **<set>** to add more than 1 animation in 1 file.

By default, all android animation instructions are applied simultaneously. To make them occur sequentially, you must specify the startOffset attribute, as shown in the example below. Screen coordinates (not used in this example) are (0,0) at the upper left hand corner, and increase as you go down and to the right. Some values, such as pivotX, can be specified relative to the object itself or relative to the parent. Be sure to use the proper format for what you want (“50” for 50% relative to the parent, or “50%” for 50% relative to itself).

  1. Scale: this android animation is used to increase or decrease size of any object.
  2. Alpha: this android animation is used to increase or decrease transparency of any object.
  3. Translate: this android animation is used to move object from 1 place to another place.
  4. Rotate: this android animation is used to rotate any object.

For example :

Create new file in “res/anim” names “test_anim.xml” (if anim directory doesn’t exist in res directory, then create manually) Inside test_anim.xml we can write our code like

<rotate android:duration="3000" 
        android:toDegrees="80" />

by this code we can rotate any object, android animation will be set through java code to any object.

For example to set this android animation to button write below code:

Button btn = (Button) findViewById(;
Animation animation = AnimationUtils.loadAnimation(context,R.anim.test_anim);

That’s it.

continue to next post for detailed info about android animation in google material design