Android Animation's scaleanimation application detailed

Source: Internet
Author: User

This section explains the implementation of Scaleanimation animation in the application, the need for friends can refer to the following

4 animations are available in Android:
Alphaanimation Transparency Animation effect
Scaleanimation Zoom Animation effect
Translateanimation Displacement Animation effect
Rotateanimation Rotate animation effect

This section explains Scaleanimation animations,
Scaleanimation (float FromX, float toX, float fromY, float toy,int pivotxtype, float pivotxvalue, int pivotytype, float PIV Otyvalue)
Parameter description:

Copy CodeThe code is as follows:
Float FromX scaling on x-coordinate when animation starts
Float ToX stretch Size on x-coordinate at end of animation
Float FromY stretch size on y-coordinate when animation starts
Float ToY stretch size on y-coordinate at end of animation
int Pivotxtype animation on x-axis relative to object position type
Float Pivotxvalue The start position of the animation relative to the X coordinate of the object
int Pivotytype animation in y-axis relative to object position type
Float Pivotyvalue The start position of the animation relative to the y-coordinate of the object


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);
/** Setting the Zoom animation */
Final scaleanimation animation =new scaleanimation (0.0f, 1.4f, 0.0f, 1.4f,
Animation.relative_to_self, 0.5f, Animation.relative_to_self, 0.5f);
Animation.setduration (2000);//Set animation duration
/** Common Methods */
Animation.setrepeatcount (int repeatcount);//Set the number of repetitions
Animation.setfillafter (Boolean);//Whether the animation stays in the finished state after execution
Animation.setstartoffset (long Startoffset);//wait 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:

Articles you may be interested in:
      • Android activity jump animation various effects finishing
      • Android for flip Flip animation effect
      • Android opening animation class complete implementation code
      • Android uses XML to do an in-depth analysis of animated UI
      • Android 3D rotation animation effect for decomposition
      • Android inhalation animation effect decomposition
      • Example code for Android simple picture animation playback
      • Android Tween Animation rotateanimation implementation of the picture rotation effect example Introduction
      • Android Four animation effects call implementation code
      • 3D Flip Effect Implementation function analysis of Android animation
      • Android Animation's rotateanimation application detailed
      • Android implementation of the activity interface to change the way to add animation effects

Scaleanimation application of Android animation

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.