我想将视图从(-100,0)移动到(-50,1)到(10,1)到(100,2)步 步。 我试过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);
我错过了什么吗? 感谢。
答案 0 :(得分:0)
我认为问题是集合一次执行所有动画
您可以尝试使用
http://developer.android.com/reference/android/view/animation/Animation.AnimationListener.html
添加下一步onAnimationEnd()