fillBefore是指动画结束时画面停留在第一帧,fillAfter是指动画结束是画面停留在最后一帧。最关键的问题是,这2个参数不能在xml中设置,这是没有用的。必须在java代码中设置。比如
setFillAfter(true);
setFillBefore(false);
这样动画结束时,停在最后一帧。
myAnimation= AnimationUtils.loadAnimation(this,R.anim.myanim);
myImageView = (ImageView) this.findViewById(R.id.myImageView);
myAnimation.setFillAfter(true);
myImageView.startAnimation(myAnimation);
也可以放在xml文件中,在<set android:fillAfter="true"> 这里是可以的。放在scale等后面是不行的。
<?xml version="1.0" encoding="utf-8"?><!-- XML的版本以及编码方式 --> <set android:fillAfter="true" xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:interpolator= "@android:anim/accelerate_decelerate_interpolator" android:fromXScale="0.0" android:toXScale="1.4" android:fromYScale="0.0" android:toYScale="1.4" android:pivotX="10%" android:pivotY="10%" android:fillAfter="false" android:duration="10000" /> <!-- 尺寸的变换 --> </set>