Reputation: 829
When I add this animation to an image view in a relative layout, the image jumps to a larger scale before smoothly growing and shrinking (then jumping back to its original size).
When I comment out the second "scale" animation in the file shown below, this unexpected jumping doesn't occur. Why? I cannot figure it out.
MainActivity:
ImageView image = (ImageView)findViewById(R.id.imageView1);
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.myanimation);
image.startAnimation(animation);
myanimation.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="3.0"
android:toYScale="3.0" >
</scale>
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"
android:fromXScale="3.0"
android:fromYScale="3.0"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="2000"
android:toXScale="1.0"
android:toYScale="1.0" >
</scale>
</set>
Upvotes: 5
Views: 927
Reputation: 8153
Try following:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="3.0"
android:toYScale="3.0" >
</scale>
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="2000"
android:toXScale="0.33"
android:toYScale="0.33" >
</scale>
</set>
Upvotes: 5