1

私の 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 では失敗します。ドローアブルは 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>
4

1 に答える 1

3

コンテナー ビューのメソッドを呼び出す直前にコードを移動したところ、show現在は 2.3 と 4.0 の両方で機能しています。

Animation rotation = AnimationUtils.loadAnimation(MainView.this, R.animator.rotate);
progressDialog.findViewById(R.id.progress).startAnimation(rotation);
progressDialog.show();
于 2012-07-16T09:14:53.670 に答える