title: Android Image rotation
body: <p>I want an image to rotate for an indefinite time........which means I want to loop it. This is my attempt but unfortunately it does not work. Any suggestions?   </p>
  
  <pre><code>package com.android.test;
  
  import android.app.Activity;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.graphics.Matrix;
  import android.graphics.drawable.BitmapDrawable;
  import android.os.Bundle;
  import android.widget.ImageView;
  import android.view.ViewGroup.LayoutParams;
  import android.widget.LinearLayout;
  import android.widget.ImageView.ScaleType;
  
  public class imagerotate extends Activity {
   int x=1;
   int y=3;
  
       @Override
       public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           LinearLayout linearLayout = new LinearLayout(this);
  
           while (y==3) {
     Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
  
     int width = bitmap.getWidth();
     int height = bitmap.getHeight();
  
     Matrix matrix = new Matrix();
     matrix.postRotate(x);
  
     Bitmap rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, width,height, matrix, true);
     BitmapDrawable bmd = new BitmapDrawable(rotatedBitmap);
  
     ImageView imageView = new ImageView(this);
     imageView.setImageDrawable(bmd);
     imageView.setScaleType(ScaleType.CENTER);
  
     linearLayout.addView(imageView, new LinearLayout.LayoutParams(
       LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
     setContentView(linearLayout);
  
     x+=1;
     }
       }
   }
  </code></pre>