The rotateanimation rotation coordinate system is a coordinate system (0,0) point with the rotation point. The x-axis is 0 degrees and rotates clockwise to a certain angle.
1.RotateAnimation (Fromdegrees, todegrees) [by default, the top-left vertex of the view is the rotation point].
The x-axis rotates clockwise to the starting point of the fromdegrees,
The x-axis rotates clockwise to the starting point of the todegrees.
such as fromdegrees=0,todegrees=90; the top left corner vertex is the rotation point. 0 degrees is the starting point, and 90 degrees is the endpoint. Rotated, rotated 90 degrees.
such as fromdegrees=60,todegrees=90; the top left corner vertex is the rotation point. 60 degrees is the starting point, and 90 degrees is the endpoint. Rotate the 90-60=30 degrees.
2.RotateAnimation (float fromdegrees, float todegrees, float pivotx, float pivoty)
(Pivotx,pivoty) is the rotation point. The pivotx is the offset from the left, and the Pivoty is the offset from the top. is the coordinate point relative to the upper-left corner of the view (0,0).
Assume:
View width=100px,height=100px
Rotateanimation (0,10,100,100); Rotate 10 degrees clockwise from the original position with the lower-right corner vertex as the rotation point
Rotateanimation (0,90,50,50); Rotates 90 degrees with the center point of the view as the rotation point
3.RotateAnimation (Fromdegrees, Todegrees, Pivotxtype, Pivotxvalue, Pivotytype, Pivotyvalue)
Pivotxtype, Pivotxvalue, Pivotytype, pivotyvalue rotation point type and its value.
Animation.absolute is the absolute value of the other as a percentage. This peaceful moving picture of the same, do not know can go there to see
Assume
Rotateanimation (0, Animation.relative_to_self, 0.5f, Animation.relative_to_self, 0.5f); Rotate 90 degrees by center point
Effect and Rotateanimation (0,90,50,50) in 2, rotates 90 degrees with the center point of the view as the rotation point. Same effect
New Rotateanimation (0, Centerx,centery);
The first parameter represents the starting angle of the animation, the second parameter represents the end angle of the animation, the third represents the rotation center X axis of the animation, and the fourth represents the Y axis of the animation rotation Center.
Rotateanimation.setduration (1000 * 20);
The table animation lasts 20s.
Rotateanimation.setfillafter (TRUE);
Ture indicates that the animation stops at the last position of the animation, and False indicates that the animation ends at the initial position, and defaults to false.
Mview.startanimation (rotateanimation);
Represents the start of an animation in Mview.
The following: Just look for a picture of two buttons on the line.
Rotateanimation (float fromdegrees, float todegrees, int pivotxtype, float pivotxvalue, int pivotytype, float pivotyvalue)
Parameter description:
Float fromdegrees: The start angle of the rotation.
Float todegrees: The end angle of the rotation.
int pivotxtype:x The scaling mode of the axis, you can take the value of absolute, relative_to_self, relative_to_parent.
The scaling value of the float pivotxvalue:x coordinates.
int Pivotytype:y The scaling mode of the axis, you can take the value of absolute, relative_to_self, relative_to_parent.
The scaling value of the float pivotyvalue:y coordinates.
Public classMainactivityextendsActivity {ImageView image; Button start; Button Cancel; @Override Public voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (r.layout.activity_main); Image=(ImageView) Findviewbyid (r.id.main_img); start=(Button) Findviewbyid (R.id.main_start); Cancel=(Button) Findviewbyid (r.id.main_cancel);/**Set rotation animation*/ Finalrotateanimation animation =Newrotateanimation (0f,360f,animation.relative_to_self,0.5f,animation.relative_to_self,0.5f); Animation.setduration (3000);//set the duration of an animation/**Common Methods*/ //animation.setrepeatcount (int repeatcount);//set number of repetitions//Animation.setfillafter (Boolean);//whether the animation stays in the finished state after execution//Animation.setstartoffset (long startoffset);//wait time before executionStart.setonclicklistener (NewOnclicklistener () { Public voidOnClick (View arg0) {image.setanimation (animation);/**Start Animation*/Animation.startnow ();} }); Cancel.setonclicklistener (NewOnclicklistener () { Public voidOnClick (View v) {/**End Animation*/animation.cancel ();} }); } }
Android Rotateanimation Detailed