---
title: "Animations in Android"  
description: "Hi everyone in this article I’m explaining about Animations in Android."  
author: "Manoj Pandey"  
published: 2015-02-24  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/1603/animations-in-android  
category: "android"  
tags: ["android", "android styles"]  
reading_time: 2 minutes  

---

# Animations in Android

Android provides a variety of powerful APIs for applying [animation](https://www.mindstick.com/articles/13040/seven-helpful-tips-to-start-and-grow-an-animation-video-company) to UI elements and drawing custom 2D and [3D graphics](https://www.mindstick.com/blog/302667/applying-translation-rotation-and-scaling-to-objects-in-a-3d-graphics-pipeline). The sections below provide an overview of the APIs and system [capabilities](https://www.mindstick.com/interview/490/explain-the-concepts-and-capabilities-of-assembly-in-dot-net) available and help you decide with approach is best for [your needs](https://www.mindstick.com/articles/12875/blunders-you-must-avoid-while-hiring-java-developers-to-get-the-best-fulfilling-your-needs).\

These classes provide [functionality](https://www.mindstick.com/blog/136/using-watermark-functionality-in-textbox-by-jquery) for the property animation system, which allows you to animate object [properties](https://yourviews.mindstick.com/view/81845/now-it-s-possible-to-predict-properties-of-any-molecule) of any type. int, float, and hexadecimal color values are supported by default. You can animate any other type by telling the system how to calculate the values for that given type with a custom Type Evaluator.

Adding [animations](https://www.mindstick.com/forum/160680/how-to-use-css-transitions-and-animations-in-the-webpage) to [your app](https://answers.mindstick.com/qa/33368/how-will-you-design-a-listview-which-downloads-a-lot-of-images-and-displays-in-it-without-getting-your-app-hanged-whats-the-best-possible-way) [interface](https://www.mindstick.com/articles/12036/interface-in-c-sharp) will give high quality feel to your android applications. Animations can be performed through either XML or android code. In this [tutorial](https://yourviews.mindstick.com/view/81591/semrush-tutorial-and-review-2020-how-to-use-it-to-20x-your-website-traffic) i explained how to do animations using XML notations.

##### This article is help you to create animation in your application

##### \
1. Create an android application

##### \
2. Add folder in resource file. res/anim

##### \
3. Create myanim.xml file in anim folder and resource type must be Property

##### Animation.

##### \
![Animations in Android](https://www.mindstick.com/mindstickarticle/05fcfbb9-5e3e-4300-84eb-ca213d7d28cd/images/02cac495-89ed-468a-8606-23fe51c9c127.png)

##### And add following code

```
<?xml version="1.0" encoding="utf-8"?><set>     <scale        xmlns:android="http://schemas.android.com/apk/res/android"        android:duration="5000"        android:fromXScale="0.5"        android:fromYScale="0.5"        android:pivotX="50%"        android:pivotY="50%"        android:toXScale="3.0"        android:toYScale="3.0" >    </scale> </set>
```

4. My activity_main.xml file

```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:paddingBottom="@dimen/activity_vertical_margin"    android:paddingLeft="@dimen/activity_horizontal_margin"    android:paddingRight="@dimen/activity_horizontal_margin"    android:gravity="center"    android:paddingTop="@dimen/activity_vertical_margin"    tools:context=".MainActivity" >          <ImageView        android:id="@+id/myImage"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:src="@drawable/ic_launcher" /> </LinearLayout>
```

5. Add following code in MainActivity.class

```
package com.example.androidanimation; import android.os.Bundle;import android.app.Activity;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.view.View.OnClickListener;import android.view.animation.Animation;import android.view.animation.AnimationUtils;import android.widget.ImageView; public class MainActivity extends Activity {                ImageView imageView;                 @Override                protected void onCreate(Bundle savedInstanceState) {                                super.onCreate(savedInstanceState);                                setContentView(R.layout.activity_main);                                // Animations can add subtle visual cues that notify users about what's                                // going on in your app and improve their mental model of your app's                                // interface.                                final Animation animation = AnimationUtils.loadAnimation(                                                                getApplicationContext(), R.anim.myanim);                                                                imageView = (ImageView) findViewById(R.id.myImage);                                imageView.setOnClickListener(new OnClickListener() {                                                 @Override                                                public void onClick(View v) {                                                                // TODO Auto-generated method stub                                                                imageView.startAnimation(animation);                                                }                                });                 }                 @Override                public boolean onCreateOptionsMenu(Menu menu) {                                // Inflate the menu; this adds items to the action bar if it is present.                                getMenuInflater().inflate(R.menu.main, menu);                                return true;                } } 
```

Now run your application

\
![Animations in Android](https://www.mindstick.com/mindstickarticle/05fcfbb9-5e3e-4300-84eb-ca213d7d28cd/images/66bbaad0-623b-4c43-8dc3-82dccf26a837.png)

\
After click in image

![Animations in Android](https://www.mindstick.com/mindstickarticle/05fcfbb9-5e3e-4300-84eb-ca213d7d28cd/images/7a25d762-f489-4400-8d6a-e36ba41229d0.png)

---

Original Source: https://www.mindstick.com/articles/1603/animations-in-android

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
