Tom*_*lin 5 android scale android-animation
当我将此动画添加到相对布局中的图像视图时,图像会在平滑增长和收缩(然后跳回其原始大小)之前跳转到更大的比例。
当我注释掉下面显示的文件中的第二个“缩放”动画时,不会发生这种意外的跳跃。为什么?我想不明白。
主要活动:
ImageView image = (ImageView)findViewById(R.id.imageView1);
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.myanimation);
image.startAnimation(animation);
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
尝试以下操作:
<?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>
Run Code Online (Sandbox Code Playgroud)