給一個控制元件新增一個旋轉動畫
阿新 • • 發佈:2018-11-20
// 均勻旋轉動畫 private RotateAnimation rotateAnimation; rotateAnimation = (RotateAnimation) AnimationUtils.loadAnimation(getContext(), R.anim.rotating_anim); // 新增勻速轉動動畫 LinearInterpolator lir = new LinearInterpolator(); rotateAnimation.setInterpolator(lir); ivOpen.startAnimation(rotateAnimation); ivOpen.clearAnimation(); <?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="800" android:fromDegrees="0" android:pivotX="50%" android:pivotY="50%" android:repeatCount="-1" android:toDegrees="359" > </rotate>