fillBefore是指動畫結束時畫面停留在第一幀,fillAfter是指動畫結束是畫面停留在最後一幀。最關鍵的問題是,這2個參數不能在xml中設置,這是沒有用的。必須在java代碼中設置。好比
setFillAfter(true);
setFillBefore(false);
這樣動畫結束時,停在最後一幀。html
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>
轉至:http://www.cnblogs.com/lxmanutd/archive/2011/07/25/2116687.htmljava