小圖標轉動

如何讓一個刷新的小圖標轉起來?so easy,寫個屬性動畫xml,然後在代碼中加載進來,在view中使用動畫就搞定,在此記錄一下。

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="2000"
    android:fillAfter="false"
    android:fillBefore="true"
    android:fillEnabled="true"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"

    android:repeatCount="infinite"
    android:repeatMode="restart"
    android:startOffset="0"
    android:toDegrees="360">

</rotate>
private Animation anim;
anim = AnimationUtils.loadAnimation(getContext(), com.example.R.anim.refreash_animation);
refresh_iv.startAnimation(anim);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章