我知道 API 级别 19 支持 ObjectAnimators 上的 pause() 和 resume()。但在我的 API 级别 14 的项目中,我有一个 ObjectAnimator,它应用于图像视图以旋转它。我想在触摸时暂停 ObjectAnimator 提供的动画,并从图像视图所在的位置恢复它(在触摸之前)。
所以我试图保存当前播放时间并取消我的 stopAnimation() 函数上的对象动画师。
private void stopAnimation(){
currentTime = mGlobeAnimator.getCurrentPlayTime();
mGlobeAnimator.cancel();
}
在 startAnimation() 函数中,我重新创建动画器,将其目标设置为图像视图,设置保存的播放时间并启动它。
private void startAnimation(Context context, View view, float startAngle) {
ObjectAnimator globeAnimatorClone = (ObjectAnimator)AnimatorInflater.loadAnimator(context, R.animator.rotate_globe);
globeAnimatorClone.setTarget(mImageView);
globeAnimatorClone.setCurrentPlayTime(currentTime);
globeAnimatorClone.start();
}
这不起作用。有人会帮助请任何指针来暂停和恢复动画师为 19 岁之前的 API 级别提供的动画吗?