15th chapter, Cycle Animation (Android)

Source: Internet
Author: User

Package Com.example.coco_demo02;import Android.app.activity;import Android.os.bundle;import Android.view.animation.animation;import Android.view.animation.translateanimation;import Android.widget.imageview;import android.widget.linearlayout;/* * This method is suitable for these four basic animations: *alphaanimation Transparency Change * Rotateanimation screen rotation *scaleanimation size zoom *translateanimation position Move */public class Mainactivity extends Activity {@ overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);//Instantiate Layout LinearLayout Llayout = new LinearLayout (this);//Added to this activity This.setcontentview (llayout);//Instantiate picture, set high width, and add to layout imageview image = New ImageView (this); Image.setmaxheight (image.setmaxwidth); image.setpadding (10, 0, 0, 0); Image.setimageresource (R.drawable.ic_launcher); Llayout.addview (image);//Set position, Parameter: Start x, start Y, end X, End Ytranslateanimation animation = new Translateanimation (0, 0, 0, 50);//Run Time animation.setduration (3000);//Repeat number, Do not write only once Animation.setrepeatcount (animation.infinite);//repeating mode, reversE is the beginning to the end, and then the animation reverts to the beginning Animation.setrepeatmode (animation.reverse);//The position after the animation//Animation.setfillafter (TRUE);// Animate the picture image.setanimation (animation);//animation starts Animation.start ();}}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

15th chapter, Cycle Animation (Android)

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.