[英]Android: Add delay between the in and out animation of ViewAnimator
[英]JavaFX : Rotated animation delay between cycles
我使用以下代碼為基於RotatedTranstion的ImageView創建了動畫:
ImageView icon = ImageCache.getImage("refresh.png");
RotateTransition rotateTransition = new RotateTransition(Duration.millis(2000), icon);
rotateTransition.setByAngle(360.0);
rotateTransition.setCycleCount(Timeline.INDEFINITE);
rotateTransition.play();
這將產生以下動畫:
就像您在動畫gif中注意到的那樣,動畫不是連續的,即動畫周期之間的延遲很小(暫停)。
我試圖看一下API,但無法弄清楚是什么原因造成了這種延遲以及如何擺脫這種延遲。
每個周期之間的明顯停頓是由interpolator引起的,默認情況下使用Interpolator.EASE_BOTH
(因此,它在每個周期的末尾減速並在開始時加速)。
要刪除它,只需將插值器設置為Interpolator.LINEAR
:
rotateTransition.setInterpolator(Interpolator.LINEAR);
每個Transition
周期的加速和減速時間均由Interpolator
器控制。 Transition使用的默認Interpolator
器是Interpolator.EASE_BOTH
。
您需要線性插值,因此將其添加到代碼中:
rotateTransition.setInterpolator(Interpolator.LINEAR);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.