title: how to rotate an image continuously?
body: <p>I am trying to rotate this image by using a thread. what should I do?</p>
  <pre class="lang-java prettyprint-override"><code>public class Start extends Activity {
      View base;
      Bitmap rotate, base1, rotate1;
      ImageView rotator;
      float angle, pivX, pivY;
      
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          
          super.onCreate(savedInstanceState);
          setContentView(R.layout.start);
          base = findViewById(R.id.base);
          rotator = (ImageView) findViewById(R.id.rotator);
          pivX = (rotator.getLeft()) / 2;
          pivY = (rotator.getTop()) / 2;
      
          Thread thread = new Thread() {
              @Override
              public void run() {
                  for (angle = 0; angle &lt; 50; angle++) {
                      Matrix matrix = new Matrix();
                      rotator.setScaleType(ScaleType.MATRIX); // required
                      matrix.postRotate((float) angle, pivX, pivY);
                      rotator.setImageMatrix(matrix);
                      if (angle == 40) {`enter code here`
                          angle = 0;
                          return;
                      }
                  }   
              }
          };
          
          thread.start();
      }
  }
  </code></pre>