我可以無限旋轉我的影像。但我的問題是影像在達到 360o 時會很快暫停,然后再次開始旋轉。即使我應用了“linear_interpolator”,它也會發生同樣的情況。我想要做的是影像在下一輪開始時根本不會暫停。所以它必須在任何角度以相同的速度無限旋轉。
這是我的 - 代碼。謝謝
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:interpolator="@android:anim/linear_interpolator"
android:duration="1400"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="0"
android:toDegrees="360"
android:repeatMode="restart"
android:repeatCount="infinite" />
</set>
我如何在我的代碼中呼叫它
rotate= AnimationUtils.loadAnimation(context, R.anim.loop_rotate)
binding.imgSecondLayout.startAnimation(rotate)
感謝幫助!:)
uj5u.com熱心網友回復:
只需添加animation.setRepeatCount(Animation.INFINITE)到呼叫影片的 java 類即可。
我的最終代碼在這里給出:
Animation animation = AnimationUtils.loadAnimation(getBaseContext(), R.anim.loop_rotate);
animation.setInterpolator(new LinearInterpolator());
animation.setRepeatCount(Animation.INFINITE);
animation.setDuration(1400);
youractivity.startAnimation(animation);
uj5u.com熱心網友回復:
這是由于影片完成其持續時間后的小延遲(在您的情況下為 1400 毫秒)。您可以移除此延遲以獲得流暢的影片效果。
洗掉 repeatMode 屬性并添加以下行:
android:startOffset="0" //Delay in milliseconds before the animation runs
影片將流暢無延遲
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/391297.html
