1.плавное вращение от 0 до -45: Инвертировать знак угла и setFillAfter(true)
, чтобы представление сохраняло законченную позицию анимации
RotateAnimation rotateAnimation1 = new RotateAnimation(0, 45f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotateAnimation1.setFillAfter(true); //This keeps view at animation ended position
rotateAnimation1.setStartOffset(0);
rotateAnimation1.setDuration(2000);
rotateAnimation1.setInterpolator(new LinearInterpolator());
2.плавное вращение от -45 до +45: Установите начальный угол анимации равным 0, поскольку представление уже повернуто.
// Since view already is at -45 position due to rotateAnimation1.setFillAfter(true), now start point is 0 again
RotateAnimation rotateAnimation2 = new RotateAnimation(0, -90,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotateAnimation2.setFillAfter(true);
rotateAnimation2.setStartOffset(0);
rotateAnimation2.setDuration(4000);
rotateAnimation2.setInterpolator(new LinearInterpolator());
Остальные шаги выполняются просто, следуя приведенной выше логике.