Objectanimator control of Android properties animation

Source: Internet
Author: User

Android gives us a lot of animation, how to use these animations to achieve the effect we need? Today, we summarize the Objectanimator animation control events.

The layout file for this purpose has only two controls: ImageView and button, not in here, let's look at the implementation of the activity:

 Public classTwoactivityextendsactivity{Privatebutton button;PrivateImageView ImageView; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_main); Button=(Button) Findviewbyid (R.id.button);ImageView=(ImageView) Findviewbyid (R.id.imageview); Button.setonclicklistener (NewView.onclicklistener () {@Override Public voidOnClick (view view) {Objectanimator Animator=NewObjectanimator (). Offloat (ImageView, "alpha", 0F, 1F); Animator.setduration (1000); Animator.addlistener (NewAnimator.animatorlistener () {@Override Public voidOnanimationstart (Animator Animator) {//Start Animation EventToast.maketext (twoactivity. This, "animation Start", Toast.length_short). Show (); } @Override Public voidonanimationend (Animator Animator) {//End Animation EventToast.maketext (twoactivity. This, "End of animation", Toast.length_short). Show (); } @Override Public voidOnanimationcancel (Animator Animator) {//Cancel Event} @Override Public voidonanimationrepeat (Animator Animator) {//Recurring Events                    }                });            Animator.start (); }        });    }}

Here is the main point for you to introduce the Objectanimator AddListener () method, you can see that the implementation of this method needs to implement its internal four built-in methods, we often use the Onanimationend () method, used to render the user after the end of the animation control.

Objectanimator control of Android properties 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.