Rotating an ImageView within a Layout... how?
<p>I have a layout with an image on it (embedded in an ImageView). I need to rotate the image (let's say) 90 degrees CCW.</p>

<p>I've written code to animate the image rotating...:</p>

<pre><code>public class MainActivity extends Activity
{
    private ImageView mImageView = null;
    private Animation mRotateAnimation = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mImageView = (ImageView) findViewById(R.id.my_image);
        mRotateAnimation = AnimationUtils.loadAnimation(this, R.anim.my_rotate_90);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            mImageView.startAnimation(mRotateAnimation);
            return true;
        }
        return super.onTouchEvent(event);
    }
}
</code></pre>

<p>The image smoothly rotates 90 degrees, but then snaps back to its original state. This is what the Android documentation says will happen after an animation completes. Presumably, on the notification that the animation has ended, I'm supposed to transform the ImageView (or the underlying drawable), and possibly invalidate it to trigger a redraw.</p>

<p>All well and good, except that <strong>I can't find a way to do it, and I can't find any examples of anyone else doing it</strong>.</p>

<p>I tried using <code>getImageMatix</code>/<code>setImageMatrix</code> on <code>mImageView</code>, with no apparent effect. There are subclasses of Drawable that will rotate an image, but there is no setDrawable() method on ImageView, so I don't see how to use one.</p>

<p>I searched the examples; though a few of them involve animation and rotation (notably LunarLander), none of them are animating an ImageView, and then leaving it in some transformed state.</p>

<p>Surely I'm missing something simple here... aaaargh, how do you rotate an ImageView within a layout?</p>

<p>Thanks.</p>
