如何让imageview不停的旋转?

How to make imageview constantly spin?

<ImageView
      android:id="@+id/imageView1"
      android:layout_width="300dp"
      android:layout_height="300dp"
      android:src="@drawable/zaid1"
      android:layout_centerVertical="true"
      android:layout_centerHorizontal="true" />

我在 activity 的中间有一个 imageview,我该如何让它无限旋转 360 度?

尝试使用RotateAnimation:

RotateAnimation rotateAnimation = new RotateAnimation(0, 360f,
    Animation.RELATIVE_TO_SELF, 0.5f,
    Animation.RELATIVE_TO_SELF, 0.5f);

rotateAnimation.setInterpolator(new LinearInterpolator());
rotateAnimation.setDuration(500);
rotateAnimation.setRepeatCount(Animation.INFINITE);

findViewById(R.id.imageView1).startAnimation(rotateAnimation);

或XML方式。 在 res 文件夹中创建 "anim" 文件夹。 创建一个 xml 文件,任意命名。您将在此处定义动画。

在 xml 文件中放入:

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

现在你只需加载动画:

Animation rotation = AnimationUtils.loadAnimation(this, R.anim.your_xml_name);

然后启动它:

findViewById(R.id.imageView1).startAnimation(rotation);