我知道API级别19支持ObjectAnimators上的pause()和resume().但是在API级别14的项目中,我有一个ObjectAnimator应用于Image视图来旋转它.我想在触摸时暂停ObjectAnimator提供的动画,并从图像视图所在的位置(触摸前)恢复它.
所以我试图保存当前的播放时间并取消我的stopAnimation()函数上的对象动画.
private void stopAnimation(){
currentTime = mGlobeAnimator.getCurrentPlayTime();
mGlobeAnimator.cancel();
}
Run Code Online (Sandbox Code Playgroud)
在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();
}
Run Code Online (Sandbox Code Playgroud)
这不起作用.在19岁之前,有任何人会帮忙请求暂停和恢复动画师为API级别提供的动画吗?