To Animate a picture file
1.Create a new folder "anim" inside res folder
2.Goto folder res\anim and rt ck , select "Android XML File"
3.Give a resource ="Tween Animation" and File name="rotator" , root element ="rotate"
4.Open rotator.xml , delete all its contents and copy paste the below code inside :
************************************************************************
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:interpolator="@android:anim/linear_interpolator" >
<!-- Use startOffset to give delay between animations -->
<!-- Move -->
<translate
android:duration="800"
android:fillAfter="true"
android:fromXDelta="0%p"
android:startOffset="300"
android:toXDelta="75%p" />
<translate
android:duration="800"
android:fillAfter="true"
android:fromYDelta="0%p"
android:startOffset="1100"
android:toYDelta="70%p" />
<translate
android:duration="800"
android:fillAfter="true"
android:fromXDelta="0%p"
android:startOffset="1900"
android:toXDelta="-75%p" />
<translate
android:duration="800"
android:fillAfter="true"
android:fromYDelta="0%p"
android:startOffset="2700"
android:toYDelta="-70%p" />
<!-- Rotate 360 degrees -->
<rotate
android:duration="1000"
android:fromDegrees="0"
android:interpolator="@android:anim/cycle_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="3000"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toDegrees="360" />
</set>
***************************************************************************
5.Click next ...next and Finish
6.Copy paste method in your MainActivity
public void rotateit(View v){
final ImageView myImage = (ImageView)findViewById(R.id.imageView2);
final Animation myRotation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotator);
myImage.startAnimation(myRotation);
}
7.Copy Paste any image inside your res/drawable-hdpi
8.Goto layout xml (ex: layout/activity_main.xml)
9.Select tab - Graphical Layout
10.Drag and Drop Image View , Select the the image you pasted in "res/drawable-hdpi"
11. Select the image ,goto properties
12.Make On Click ="rotateit"
13.Save and Run
more animations in http://www.androidhive.info/2013/06/android-working-with-xml-animations/
This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic. Best Android Training in chennai|Android Training in chennai with placement | Android Training in velachery
ReplyDelete