0

ImageView を元の場所と一緒に回転させようとしています (画像とビューを回転させます)。そのため、回転後、回転した画像を現在の位置でクリックすると、回転した場所でのみクリックできるはずです。

このソリューションでは、次のコードを試しています。しかし、回転は順調です。回転が終了したら、回転した場所に ImageView と Image を配置して、そこでのみクリックできるようにする必要があります。しかし、それはうまくいきません。イメージの位置軸ポイントを回転させて正しく配置することができません。この問題を解決する方法を提案してください。

fyi-Gingerbread バージョン android-9 で動作するはずです

 aniView1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.e("", "Clicked on IMAGE VIEW - 1");
            }
        });

        RotateAnimation rotate5 = new RotateAnimation(0, 150,
                Animation.INFINITE, 100, Animation.INFINITE, 250);
        //rotate5.setFillAfter(true);
        rotate5.setDuration(2000);
        rotate5.setInterpolator(new LinearInterpolator());
        aniView1.setAnimation(rotate5);

        rotate5.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {

                int newTop = (int) (aniView1.getTop() + aniView1.getWidth());

                aniView1.layout(aniView1.getLeft()-200, newTop,
                        aniView1.getRight(),
                        aniView1.getBottom() + aniView1.getMeasuredWidth());

                // aniView1.setLayoutParams(new
                // RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT));

            }
        });
4

2 に答える 2

1

これを試して。それは私のために働いていました。アニメーション化された状態はそこから永続化されます

編集:

わかりました。アプリで次のコードを使用してそれを行うことができます。

Animation rotateAnim = new RotateAnimation(0, 360, Animation.ABSOLUTE, Animation.ABSOLUTE, Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF);
        rotateAnim.setDuration(5000);
        rotateAnim.setRepeatCount(1);
        rotateAnim.setInterpolator(new AccelerateInterpolator());
        rotateAnim.setRepeatMode(Animation.REVERSE);
        rotateAnim.setFillEnabled(true);
        rotateAnim.setFillAfter(true);
于 2012-11-07T10:58:12.060 に答える
0

このファイルを android res --> anim --> loading_rotation.xml の下に置きます。

<?xml version="1.0" encoding="UTF-8"?>
<rotate
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0"
    android:toDegrees="360"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="infinite"
    android:duration="1200" 
    android:interpolator="@android:anim/linear_interpolator"/>

そしてあなたの活動で

view.startAnimation(AnimationUtils.loadAnimation(context,
                R.anim.loading_rotation));

停止したい場所で電話するだけ

view.clearAnimation();
于 2012-11-07T11:21:07.187 に答える