Learn Pain Less

HomeOur TeamContact
Android
Introduction to android animation in google material design
Pawneshwer Gupta
Pawneshwer Gupta
January 22, 2017
1 min

Table Of Contents

01
Introduction to android animation in google material design
02
For example to set this android animation to button write below code:
Introduction to android animation in google material design

Introduction to android animation in google material design

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 **res/anim/** 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

code of test_anim.xml

<rotate android:duration="3000"
android:fromDegrees="0"
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(R.id.my_button);
Animation animation = AnimationUtils.loadAnimation(context,R.anim.test_anim);
btn.startAnimation(animation);

That’s it.

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

Subscribe to our newsletter!

We'll send you the best of our blog just once a month. We promise.

Tags

Animationmaterial designmaterial motion

Share


Pawneshwer Gupta

Pawneshwer Gupta

Software Developer

Pawneshwer Gupta works as a software engineer who is enthusiastic in creating efficient and innovative software solutions.

Expertise

Python
Flutter
Laravel
NodeJS

Social Media

Related Posts

Open Close effect google material design
Open Close effect google material design
January 22, 2017
1 min
Bring Your App to Life: Creating Horizontal ListView Animations with Flutter
Flutter
Bring Your App to Life: Creating Horizontal ListView Animations with Flutter
January 05, 2023
1 min
Learn Pain Less  © 2024, All Rights Reserved.
Crafted with by Prolong Services

Quick Links

Advertise with usAbout UsContact Us

Social Media