How do I do animation in an imageview with the animation file in XML?
How do I do animation in an imageview with the animation file in XML?
You need to start by seeing this: View Animation
Here's an example of how we can do Blink Animation
. What is the type of animation that winks to view .
blink.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="700"
android:fromAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:toAlpha="1.0" />
</set>
All of these tags , fromAlpha , interporlator , ...) are explained in the link I sent it to you.
To apply the animation to any view, do this:
yourImageView.setAnimation(AnimationUtils.loadAnimation(this, R.anim.blink)).
To pause the animation in progress, do this:
yourImageView.clearAnimation();
You can find more examples of animations at: Demos API