如何在android上通过TranslateImation逐步移动视图
我想逐步将视图从(-100,0)移动到(-50,1)到(10,1)到(100,2) 步 我试着翻译。但我失败了。 它只在第一步起作用,之后移动,不像我设定的那样 这是我的代码:如何在android上通过TranslateImation逐步移动视图,android,android-animation,translate-animation,Android,Android Animation,Translate Animation,我想逐步将视图从(-100,0)移动到(-50,1)到(10,1)到(100,2) 步 我试着翻译。但我失败了。 它只在第一步起作用,之后移动,不像我设定的那样 这是我的代码: x1 = (0-layoutW); x2 = (45*Constant.metricW-layoutW); y1 = layoutH; y2 = ((356-layoutH)*Constant.metricH); Animation step1 = new TranslateAnimation(
x1 = (0-layoutW);
x2 = (45*Constant.metricW-layoutW);
y1 = layoutH;
y2 = ((356-layoutH)*Constant.metricH);
Animation step1 = new TranslateAnimation(
Animation.ABSOLUTE, x1, Animation.ABSOLUTE, x2,
Animation.ABSOLUTE, y1, Animation.ABSOLUTE, y2 );
step1.setStartOffset(300);
step1.setDuration(100);
step1.setInterpolator(new AccelerateInterpolator());
animationSet.addAnimation(step1);
x1 = (45*Constant.metricW-layoutW);
x2 = (86*Constant.metricW-layoutW);
y1 = ((356-layoutH)*Constant.metricH);
y2 = ((288-layoutH)*Constant.metricH);
Animation step2 = new TranslateAnimation(x1, x2, y1, y2);
step2.setStartOffset(400);
step2.setDuration(100);
step2.setInterpolator(new AccelerateInterpolator());
step2.setFillAfter(true);
animationSet.addAnimation(step2);
我错过什么了吗?
谢谢。我认为问题在于布景一次播放所有动画 你可以试试看 添加下一步onAnimationEnd()