我正在使用RotateAnimation旋轉要用作Android中自定義循環微調器的圖像。這是我的rotate_indefinitely.xml文件,放置在res/anim/:<?xml version="1.0" encoding="UTF-8"?><rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="0" android:toDegrees="360" android:pivotX="50%" android:pivotY="50%" android:repeatCount="infinite" android:duration="1200" /> 當我將此應用到我的ImageViewusing時AndroidUtils.loadAnimation(),它很好用!spinner.startAnimation( AnimationUtils.loadAnimation(activity, R.anim.rotate_indefinitely) );一個問題是,圖像旋轉似乎在每個循環的頂部暫停。換句話說,圖像旋轉360度,短暫暫停,然后再次旋轉360度,依此類推。我懷疑問題在于動畫使用的是默認插值器,如android:iterpolator="@android:anim/accelerate_interpolator"(AccelerateInterpolator),但我不知道如何告訴它不要插值動畫。如何關閉插值(如果確實存在問題)以使動畫循環流暢?
3 回答

收到一只叮咚
TA貢獻1821條經驗 獲得超5個贊
我也遇到了這個問題,并嘗試在xml中設置線性插值器而沒有成功。對我有用的解決方案是在代碼中將動畫創建為RotateAnimation。
RotateAnimation rotate = new RotateAnimation(0, 180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotate.setDuration(5000);
rotate.setInterpolator(new LinearInterpolator());
ImageView image= (ImageView) findViewById(R.id.imageView);
image.startAnimation(rotate);
- 3 回答
- 0 關注
- 534 瀏覽
添加回答
舉報
0/150
提交
取消