4

定点を中心に連続して画像を 360 度回転させたいと思います。私はすでに次のようないくつかの例を見てきました。

RotateAnimation anim = new RotateAnimation(0, 360,150,150);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(2000);
[imageview].startAnimation(anim);

これにより画像が回転しますが、円弧/円形のパスで回転します。すなわち。画像は円を描くように移動/回転していますが、開始位置に固定されていません。

私が基本的に望んでいるのは、WindMill の腕の回転を模倣することです。

何かご意見は?

4

3 に答える 3

7

このコードを使用

RotateAnimation rotateAnimation1 = new RotateAnimation(0, 360,
        Animation.RELATIVE_TO_SELF, 0.5f,
        Animation.RELATIVE_TO_SELF, 0.5f);
rotateAnimation1.setInterpolator(new LinearInterpolator());
rotateAnimation1.setDuration(duration);
rotateAnimation1.setRepeatCount(0);
img.startAnimation(rotateAnimation1);

これにより、画像が固定された位置で回転します。つまり、画像自体を中心に回転します。

于 2012-12-31T12:59:54.803 に答える
0

わかりましたので、微調整した後、これが完全に機能するようになりました。Macarse が言ったように、ImageView.

この問題を解決するには、あなたがしなければならないことは、あなたのImageView中にあなたを置くことだけですRelativeLayout:

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"        
    >

    <ImageView
        android:id="@+id/imageview"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:src="@drawable/image"
        />

</RelativeLayout>
于 2011-03-07T16:05:38.003 に答える
-1

imageview.. のピボット ポイントを x = imgView.getWidth()/2、および y = imgView.getHeight()/2 に設定します。

于 2015-03-24T13:45:19.800 に答える