RotateAnimation for Android Animation

Source: Internet
Author: User

Android provides 4 Animation:
AlphaAnimation transparency animation effect
ScaleAnimation scaling animation effect
TranslateAnimation displacement animation effect
RotateAnimation rotation animation effect

This section describes the RotateAnimation animation,
RotateAnimation (float fromDegrees, float toDegrees, int limit txtype, float limit txvalue, int limit tytype, float limit tyvalue)
Parameter description:
Float fromDegrees: the starting angle of rotation.
Float toDegrees: the end angle of the rotation.
Int limit txtype: The scaling mode of the X axis. values include ABSOLUTE, RELATIVE_TO_SELF, and RELATIVE_TO_PARENT.
Float limit txvalue: The scaling value of X coordinates.
Int equaltytype: The scaling mode of the Y axis. values include ABSOLUTE, RELATIVE_TO_SELF, and RELATIVE_TO_PARENT.
Float tytyvalue: The scaling value of Y coordinates.
Code:Copy codeThe Code is as follows: public class MainActivity extends Activity {
ImageView image;
Button start;
Button cancel;
@ Override
Public void onCreate (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 the rotation animation */
Final RotateAnimation animation = new RotateAnimation (0f, 360f, Animation. RELATIVE_TO_SELF,
0.5f, Animation. RELATIVE_TO_SELF, 0.5f );
Animation. setDuration (3000); // sets the animation duration.
/** Common methods */
// Animation. setRepeatCount (int repeatCount); // you can specify the number of repetitions.
// Animation. setFillAfter (boolean); // whether the animation is in the running state after execution
// Animation. setStartOffset (long startOffset); // the waiting time before execution
Start. setOnClickListener (new OnClickListener (){
Public void onClick (View arg0 ){
Image. setAnimation (animation );
/** Start animation */
Animation. startNow ();
}
});
Cancel. setOnClickListener (new OnClickListener (){
Public void onClick (View v ){
/** End animation */
Animation. cancel ();
}
});
}
}

Effect:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.