Hi,

There is absolutely no need to do all these fancy computations
yourself. Instead you can use the following constructor (or better
yet, define the animation in XML):

RotateAnimation(float fromDegrees, float toDegrees, int pivotXType,
float pivotXValue, int pivotYType, float pivotYValue)

Here is an example:

new RotateAnimation(0.0f, 180.0f, Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);

This animation will rotate about the center of the animated View.

On Sun, Jan 18, 2009 at 2:04 AM, skink <[email protected]> wrote:
>
>
>
> Mark Murphy wrote:
>> Rotate with unknown pivot. If you're seeing a rotation around the center
>> point of the View with the parameters I gave you, then obviously there's
>> something a wee bit off with my View.
>>
>> Hmmm...I have paddingRight and paddingTop values in the layout for this
>> ImageView. I wonder if the animation is taking those into account. That
>> would explain why 10, 20 would be close to the correct values when I
>> hard-wired them in -- the 20 would be the 10px paddingTop plus roughly
>> half of the image itself.
>
> ok, i found it.
>
> animation stuff works OK: it rotates tho whole view (not image
> bounds), run hierarchyviewer and
> you'll see that pivot is ok.
>
> if you try to rotate image itself, try this
>
> ImageView iv = (ImageView) findViewById(R.id.iv);
> Matrix matrix = iv.getImageMatrix();
> RectF dst = new RectF();
> matrix.mapRect(dst, new RectF(iv.getDrawable().getBounds()));
> Log.d("Test", "Dst " + dst);
> RotateAnimation a = new RotateAnimation(0, 360, iv.getPaddingLeft() +
> dst.centerX(), iv.getPaddingTop() + dst.centerY());
> a.setDuration(5000);
> iv.startAnimation(a);
>
>
> >
>



-- 
Romain Guy
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to