How to define flip animation
I want to make flip like animation of my ImageView after I click on that. My intent is to shrink width of an image to 0 and immediately after that expand it back to 1.0. This should simulate flip of the image.
This is what I actually have. After click on the image it shrink image from 1.0 to 0.
My question is how to continue with expanding part of animation?
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<scale
android:interpolator="@android:anim/linear_interpolator"
android:fromXScale="1.0"
android:toXScale="0.0"
android:fromYScale="1.0"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="200" />
</set>
EDIT
I added another block for reverse part of animation but it does not work as expected. It seem that startOffset is not开发者_Go百科 taken in effect or something like that. In other words animation is messed-up it seems that also first part of animation is affected by this additional code. What I am doing wrong?
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<scale
android:interpolator="@android:anim/linear_interpolator"
android:fromXScale="1.0"
android:toXScale="0.0"
android:fromYScale="1.0"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="200" />
<set android:startOffset="200">
<scale
android:interpolator="@android:anim/linear_interpolator"
android:fromXScale="0.0"
android:toXScale="1.0"
android:fromYScale="1.0"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="200" />
</set>
</set>
Bury another <set> <scale /> </set>
inside your first set, but after the initial scale. This will make them fire sequentially.
See this page for an example. http://developer.android.com/guide/topics/graphics/view-animation.html
After next R&D I found that this piece of code exactly do what I want it to do.
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<scale
android:fromXScale="1.0"
android:toXScale="0.0"
android:fromYScale="1.0"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="200"
android:repeatCount="2"
android:repeatMode="reverse"/>
</set>
It means that I added repeatMode
and repeatCount
to animation definition ant this works as I expected.
精彩评论