Android 旋轉動畫,停止和持續旋轉

旋轉180度後停止

        RotateAnimation rotate;
rotate =new RotateAnimation(0f,180f,Animation.RELATIVE_TO_SELF, 
                        0.5f,Animation.RELATIVE_TO_SELF,0.5f);
                rotate.setDuration(1000);
                rotate.setFillAfter(true);
                image.startAnimation(rotate);

持續旋轉,不停止

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false" >

    <rotate
        android:duration="2000"
        android:fromDegrees="0"
        android:interpolator="@android:anim/linear_interpolator"
        android:pivotX="50%"
        android:pivotY="50%"
        android:repeatCount="-1"
        android:repeatMode="restart"
        android:startOffset="-1"
        android:toDegrees="+360" />

</set>


rotate = AnimationUtils.loadAnimation(MychoiceActivity.this, R.anim.dialog_loading_animation);
                image.startAnimation(rotate);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章