Two ways to implement Android animation animation effects

Source: Internet
Author: User

Animation animation effect of two implementation methodsNote: This example is alphaanimation effect, as for other effects, change the object. 1. Java file Code Control Add and start animation animation
Add animation effect Alphaanimation animation = new Alphaanimation (0.3f, 1.0f);//Set the duration of the secondary Effect Animation.setduration (2000);// Sets the listener event for the animation Animation.setanimationlistener (new Animationlistener () {@Overridepublic void Onanimationstart (Animation Animation) {//Animation start listener event//do something ...} @Overridepublic void Onanimationrepeat (Animation Animation) {} @Overridepublic void Onanimationend (Animation Animation {//Animation end Listener event//do something ...}}); /Start animation view.startanimation (animation);

2.. xml file code load XML start animation Alpha_out.xml fade out effect
<?xml version= "1.0" encoding= "Utf-8"?><!--android:duration= "@android: Integer/config_mediumanimtime"-- ><set xmlns:android= "http://schemas.android.com/apk/res/android" ><alpha android:fromalpha= "1.0" Android:toalpha= "0" android:duration= "$"/> <!--transparency Control animation effect Alpha        floating-point value: The        Fromalpha property is the transparency        at the beginning of the animation The Toalpha   property is the transparency description at the end of the animation        :         0.0 indicates full transparency        1.0 represents a full opacity                     above the value of the float data type between 0.0-1.0 and a numeric                long integer value:  The Duration property is an animation duration        Description: The                          time is in milliseconds--></set>

Code load XML:
Property:
Private Animation anim;private Animationlistener Animlis;
Load:
Initialize the animation listener event Animationlisteneranimlis = new Animationlistener () {@Overridepublic void Onanimationstart (Animation arg0) { The animation starts to listen for events//do something ...} @Overridepublic void Onanimationrepeat (Animation arg0) {} @Overridepublic void Onanimationend (Animation arg0) {// Animation End Listener Event//do something...tv.setvisibility (view.gone);}};/ /Load Xmlanim = Animationutils.loadanimation (this, r.anim.alpha_out);//Set Listener event Anim.setanimationlistener (animLis);// Start animation tv.startanimation (Anim);



Two ways to implement Android animation animation effects

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.