Android Rotate Animation Example
http://www.viralandroid.com/2015/11/android-rotate-animation-example.html
In android, animation can be created from different ways using xml or java code. In this tutorial, I am going to show to create rotating animation using xml. To create animation using xml, first you have to create an xml file inside res/anim/ directory.
In this tutorial, I have used an image view and a button in xml layout file to rotate an image when button is clicked and you have to add little bit java code in your activity file.
Related:
Zoom In Animation in Android
Fade Out Animation in Android
How to Implement Ripple Effect in Android
Now, create android_rotate_animation.xml file in res/anim/ directory and add the content given below.
res/anim/android_rotate_animation.xml
Now, run your android rotate animation example application and click the Stat Rotating button.
Output:
In this tutorial, I have used an image view and a button in xml layout file to rotate an image when button is clicked and you have to add little bit java code in your activity file.
Related:
Zoom In Animation in Android
Fade Out Animation in Android
How to Implement Ripple Effect in Android
Rotate Animation Example: How to Rotate an Image in Android using XML Animation
XML Layout File
res/layout/android_rotate_animation_example.xmlNow, create android_rotate_animation.xml file in res/anim/ directory and add the content given below.
res/anim/android_rotate_animation.xml
Java Activity File
res/RotateAnimationExample.javaStrings.xml File
res/values/strings.xmlNow, run your android rotate animation example application and click the Stat Rotating button.
Output:
Fig 1: Android Rotate Animation Example |
Fig 2: Start Rotating Animation when Button is Clicked |