android animation example
Create an application that will have spinner with list of animation names. On selecting animation name , that animation should affect on the images displayed below.
File Name : E10.java
package bsr.exa;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ImageView;
import android.widget.Spinner;
public class E10 extends Activity implements OnItemSelectedListener
{
/** @author Bipin S Rupadiya , www.BipinRupadiya.blogspot.com
*
* 10) Create an application that will have spinner with list of animation names. On selecting animation
* name , that animation should affect on the images displayed below.
* */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Spinner s = (Spinner)findViewById(R.id.spinner1);
s.setOnItemSelectedListener(this);
}
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
long arg3)
{
ImageView i = (ImageView)findViewById(R.id.imageView1);
if(arg3==1)
{
Animation a = AnimationUtils.loadAnimation(this, R.anim.alpha);
i.startAnimation(a);
}
if(arg3==2)
{
Animation a = AnimationUtils.loadAnimation(this, R.anim.rotate);
i.startAnimation(a);
}
if(arg3==3)
{
Animation a = AnimationUtils.loadAnimation(this, R.anim.scale);
i.startAnimation(a);
}
if(arg3==4)
{
Animation a = AnimationUtils.loadAnimation(this, R.anim.spin);
i.startAnimation(a);
}
if(arg3==5)
{
Animation a = AnimationUtils.loadAnimation(this, R.anim.translate);
i.startAnimation(a);
}
}
public void onNothingSelected(AdapterView<?> arg0)
{
}
}
File Name : String.xml
<?xml version="1.0"
encoding="utf-8"?>
<resources>
<string name="hello">www.BipinRupadiya.blogspot.com</string>
<string name="app_name">E10</string>
<color name="bgcolor">#000000</color>
<string-array name="Animation">
<item>Select Item</item><item>Alpha</item>
<item>Rotate</item>
<item>Scale</item>
<item>Spin</item>
<item>Translate</item>
</string-array>
</resources>
File Name : alpha.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="0"
android:toAlpha="1.0"
android:fillAfter="true"
android:duration="7000"
/>
</set>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="0"
android:toAlpha="1.0"
android:fillAfter="true"
android:duration="7000"
/>
</set>
File Name : rotate.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:fromDegrees="0"
android:toDegrees="-360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="7000"
/>
</set>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:fromDegrees="0"
android:toDegrees="-360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="7000"
/>
</set>
File Name :scale.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:pivotX="50%"
android:pivotY="50%"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="2.0"
android:toYScale="2.0"
android:duration="2500"
/>
</set>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:pivotX="50%"
android:pivotY="50%"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="2.0"
android:toYScale="2.0"
android:duration="2500"
/>
</set>
File Name : spin.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:fromDegrees="0"
android:toDegrees="360"
android:duration="2000"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
/>
</set>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:fromDegrees="0"
android:toDegrees="360"
android:duration="2000"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
/>
</set>
File Name : translate.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="110"
android:toXDelta="-120"
android:duration="4000"
android:fillAfter="true"
android:fromYDelta="190"
android:toYDelta="0"
/>
</set>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="110"
android:toXDelta="-120"
android:duration="4000"
android:fillAfter="true"
android:fromYDelta="190"
android:toYDelta="0"
/>
</set>
AndroidManifest.xml
<?xml version="1.0"
encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0"
package="bsr.exa">
<uses-sdk android:minSdkVersion="8"
/>
<application android:icon="@drawable/icon"
android:label="@string/app_name">
<activity android:label="@string/app_name"
android:name="E10">
<intent-filter>
<action android:name="android.intent.action.MAIN"
/>
<category android:name="android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
</application>
</manifest>
Labels:
Android,
Mobile Computing
Subjects
- WordPress
- Mobile Computing-4649303 Practical Solution
- Android Programming New Syllabus Theory
- PHP LAMP Question Bank
- PHP LAMP Theory
- Step by Step Android Example
- Android Practical
- Android Theory
- Android Question Bank
- Networking FON Practical
- Networking FON Theory
- OS Practical
- OS Theory
- HTML
- JavaScript
- J2EE WTAD Theory
- J2EE WTAD Question Bank
- J2EE WTAD Quick Guide
- J2EE WTAD GTU Papers
- J2EE WTAD Practical
- Python
- JAVA Theory
- JAVA Practical
- MIS
Categories
- Android (55)
- c (11)
- Configure Tomcat7 (2)
- CSS (3)
- Decryption (16)
- Difference (1)
- Encryption (16)
- Error Detection and Correction Techniques (3)
- FON (27)
- Framing Technic (2)
- install Tomcat (2)
- J2EE (29)
- JAVA (13)
- JavaScript (19)
- linux (8)
- OS (17)
- PHP (11)
- Protocol (3)
- SERVER SOCKET PROGRAMING (7)
- Servlet (13)
- shell script (33)
- unix (22)
- WTAD (34)
Blog Archive
-
▼
2012
(79)
-
▼
September
(22)
- Chapter 7, Memory Management
- Chapter 6, Concurrency: Deadlock and Starvation
- Chapter 5, Concurrency: Mutual Exclusion and Sync...
- Chapter 4, Threads, SMP, and Micro kernels
- Chapter 3, Process Description and Control
- Chapter 2, Operating System Overview
- Chapter 1, Computer System Overview
- menu in android tutorial
- android animation example
- android chronometer example
- spinner in android example
- listview in android
- implicit intent in android example
- addTextChangedListener in Android example
- Be a Freelances and earn $$$$
- View SQLite Database
- Write a shell script to delete zero sized files fr...
- Android Intent Example
- Hello World in Android
- SQLite Android Tutorial
- Happy Teachers' Day
- Thank you GOD
-
▼
September
(22)
Total Pageviews
© BipinRupadiya.com. Powered by Blogger.