旋转动画在android 4.0中不起作用

时间:2012-07-16 08:57:04

标签: android android-4.0-ice-cream-sandwich

在我的Android应用程序中,我以编程方式将旋转动画应用于可绘制对象:

    Animation rotation = AnimationUtils.loadAnimation(this, R.animator.rotate);
    rotation.setRepeatCount(Animation.INFINITE);
    progressDialog.findViewById(R.id.progress).startAnimation(rotation);

这在Android 2.3中运行良好,但在4.0中失败。 drawable在4.0中没有动画。 这可能是什么问题?

修改 这是我的rotate.xml文件:

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
    <rotate
        android:fromDegrees="0"
        android:toDegrees="360"
        android:pivotX="50%"
        android:pivotY="50%" 
        android:duration="2000"
        android:repeatCount="-1"
        android:interpolator="@android:anim/linear_interpolator"/>
</set>

1 个答案:

答案 0 :(得分:3)

我在调用容器视图的show方法之前移动了代码,它现在正在2.3和4.0中运行:

Animation rotation = AnimationUtils.loadAnimation(MainView.this, R.animator.rotate);
progressDialog.findViewById(R.id.progress).startAnimation(rotation);
progressDialog.show();