Panning animation effects

Source: Internet
Author: User

Img_change.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View v) {//TODO auto-generated Method Stub                FinalString StartName =Tv_start.gettext (). toString (); FinalString Finalname =Tv_final.gettext (). toString (); //Set panning animationsTranslateanimation translateanimation =NewTranslateanimation (0, 150, 0, 0); //Use accelerated modeTranslateanimation.setinterpolator (Newaccelerateinterpolator ()); //Time ConsumingTranslateanimation.setduration (3000); Translateanimation.setanimationlistener (NewAnimationlistener () {@Override Public voidOnanimationstart (Animation Animation) {//TODO auto-generated Method Stub} @Override  Public voidonanimationrepeat (Animation Animation) {//TODO auto-generated Method Stub} @Override  Public voidonanimationend (Animation Animation) {//TODO auto-generated Method StubTv_start.settext (finalname);                }                                    }); Translateanimation TranslateAnimation1=NewTranslateanimation (0, -150,0, 0); //Use accelerated modeTranslateanimation1.setinterpolator (Newaccelerateinterpolator ()); //Time ConsumingTranslateanimation1.setduration (300); Translateanimation1.setanimationlistener (NewAnimationlistener () {@Override Public voidOnanimationstart (Animation Animation) {//TODO auto-generated Method Stub} @Override  Public voidonanimationrepeat (Animation Animation) {//TODO auto-generated Method Stub} @Override  Public voidonanimationend (Animation Animation) {//TODO auto-generated Method StubTv_final.settext (StartName);                }                });                Tv_final.startanimation (TranslateAnimation1);            Tv_start.startanimation (translateanimation); }                    });

The first thing to do is to create the object, the parameter is the X value of the animation starting from the current view, the X value of the current view at the end of the animation, the animation starts from the current view's Y value, the animation ends with the current view's Y value

Translateanimation translateanimation = new Translateanimation (0, 150, 0, 0);

Set the way to move to speed up the uniform

Translateanimation.setinterpolator (New Accelerateinterpolator ());

Set animation time

Translateanimation.setduration (300);

Finally realize the monitoring, in the monitoring there are three methods, respectively, the animation began, animation overlap, the end of the animation

Translateanimation.setanimationlistener (New Animationlistener () {

@Override
public void Onanimationstart (Animation Animation) {
TODO auto-generated Method Stub

}

@Override
public void Onanimationrepeat (Animation Animation) {
TODO auto-generated Method Stub

}

@Override
public void Onanimationend (Animation Animation) {
TODO auto-generated Method Stub
Tv_start.settext (Finalname);
}

And then the animation starts.

Tv_final.startanimation (TranslateAnimation1);

Panning animation effects

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.