title: Animation using Runnable?
body: <p>I'm trying to animate an ImageView using <code>Runnable</code> and <code>Handler.postDelayed</code>. Bitmap operations all work fine but instead of the animation I get the final result of the ImageView. What is wrong in here?</p>
  
  <pre><code>final ImageView imageView = (ImageView) findViewById(R.id.imageView);
      final Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.clock_flip_top);
      final Matrix matrix = new Matrix();
      for (i = 0; i &lt; 30; i++) {
          float c = i/5;
  
          src = new float[] { 0, 0, bitmap.getWidth(), 0,
                      bitmap.getWidth(), bitmap.getHeight(), 0,
                      bitmap.getHeight() };
          dst = new float[] { 0 - c, 0, bitmap.getWidth() + c, 0,
                  bitmap.getWidth(), bitmap.getHeight(), 0,
                  bitmap.getHeight() };
  
          anim = new Runnable() {
  
              @Override
              public void run() {
                  // TODO Auto-generated method stub
  
                  matrix.setPolyToPoly(src, 0, dst, 0, src.length &gt;&gt; 1);
                  Bitmap newBitmap = Bitmap
                          .createBitmap(bitmap, 0, 0, bitmap.getWidth(),
                                  bitmap.getHeight(), matrix, true);
                  imageView.setImageBitmap(newBitmap);
                  handler.postDelayed(anim, i * 200);
  
              }
  
          };
          anim.run();
      }
  </code></pre>