Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animation Scaling Glitch

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>
like image 913
Tom McFarlin Avatar asked Sep 09 '14 04:09

Tom McFarlin


1 Answers

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>
like image 67
Niko Avatar answered Nov 18 '22 01:11

Niko