1
我想將視圖從(-100,0)移動到(-50,1)到(10,1)到(100,2)step step 。 我試過TranslateAnimation。但我失敗了。 它只適用於第一步,在移動之後不會像我設置它。如何通過Android上的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);
我錯過了什麼? 謝謝。