I would like to animate a view in my app. It should do the following in an infinite loop:
- Be fully visible for 250 ms
- Fade out over 250 ms
- Be fully invisible for 250 ms
- Fade in over 250 ms
According to some references I found on the internet, the following should work:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://ift.tt/nIICcg"
android:interpolator="@android:anim/linear_interpolator"
android:repeatCount="infinite"
android:repeatMode="restart" >
<alpha
android:duration="250"
android:startOffset="0"
android:fromAlpha="1.0"
android:toAlpha="1.0" />
<alpha
android:duration="250"
android:startOffset="250"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
<alpha
android:duration="250"
android:startOffset="500"
android:fromAlpha="0.0"
android:toAlpha="0.0" />
<alpha
android:duration="250"
android:startOffset="750"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
In practice, the view is fully visible and does not fade. Does anybody know what the problem is here?
Edit:
The code in the view in which I start the animation looks like this:
Animation myAnimation = AnimationUtils.loadAnimation(context, R.anim.my_animation);
startAnimation(myAnimation);
No comments:
Post a Comment