在我的应用程序中,我正在玩安卓翻译动画。我想将视图从屏幕右上角转换为屏幕左下角。我可以翻译视图。现在我想在中间暂停翻译几秒钟,然后我想恢复它。我已经厌倦了玩不同的插值器。这些不会给出所需的结果。有人可以告诉我如何实现这种翻译吗?
我正在分享我用于翻译的代码。
AnimationSet animationSet = new AnimationSet(true);
ScaleAnimation scale = new ScaleAnimation(1f, 2f,
1f, 2f,
ScaleAnimation.RELATIVE_TO_PARENT, .5f,
ScaleAnimation.RELATIVE_TO_PARENT, .1f);
animationSet.addAnimation(scale);
int size[] = MainActivity.getDisplaySize(this);
TranslateAnimation animation = new TranslateAnimation(-1000, 1500, 300, 850);
animationSet.addAnimation(animation);
animationSet.setDuration(6000);
animationSet.setFillAfter(false);
animationSet.setInterpolator(new FastOutLinearInInterpolator());
animationSet.setAnimationListener(new MyAnimationListener());
imageView.startAnimation(animationSet);
谢谢!
常见的解决方案是将动画拆分为 2 个单独的动画。
因此,您必须在所需的暂停后开始第二个动画。
另一种方法是在暂停时节省播放时间(( getCurrentPlayTime((并此时通过 setCurrentPlayTime(( 重新启动动画。