不同时间的图像视图的多个动画

时间:2015-06-05 08:11:36

标签: android android-animation

我希望在旋转时为螺旋路径中的图像视图设置动画。我已经使用了动画集并添加了这些动画作为第一步,因此imageview将首先向右移动,然后向下移动。 (宽度和高度是我使用DisplayMetric类型属性中的widthPixels和heightPixels方法拍摄的屏幕的宽度和高度)

        animation1 = new TranslateAnimation(Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, width-180,
        Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f);
        animation1.setInterpolator(new DecelerateInterpolator());
        animation1.setDuration(5000);

        RotateAnimation ranim = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); //, 200, 200); // canvas.getWidth() / 2, canvas.getHeight() / 2);
        ranim.setDuration(5000);
        ranim.setInterpolator(new DecelerateInterpolator());

        animation2 = new TranslateAnimation(Animation.ABSOLUTE, width - 180, Animation.ABSOLUTE, width - 180,
                Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, height - 300);
        animation2.setInterpolator(new DecelerateInterpolator());
        animation2.setDuration(7000);
        animation2.setStartOffset(5000);

        RotateAnimation ranim2 = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); //, 200, 200); // canvas.getWidth() / 2, canvas.getHeight() / 2);
        ranim2.setDuration(7000);
        ranim2.setInterpolator(new DecelerateInterpolator());
        ranim2.setStartOffset(5000);

当我运行这个时,只有animation2 + ranim2正在显示在旋转时imageview将从屏幕的右上角移动到屏幕的右下角。有人能告诉我怎么做这个动画吗? 谢谢你:)

1 个答案:

答案 0 :(得分:0)

您可以使用AnimationSet。