Android Background Code settings animation

Source: Internet
Author: User

1. Set Rotation animation

Final rotateanimation animation =new rotateanimation (0f,360f,animation.relative_to_self, 0.5f,animation.relative_to _self,0.5f);

Animation.setinterpolator (New Linearinterpolator ());  The linearinterpolator represents a uniform rate of animation.setduration (3000);//Set animation duration animation.setrepeatcount (animation.infinite); Repeat multiple times, can also use specific number of times ll_earn_circle_bg.startanimation (animation);  LL_EARN_CIRCLE_BG  is a linearlayout control

2. Set displacement animation

/*** Cycletimes The number of repetitions of animation *@paramCycletimes*/     Public voidShakeanimation (intcycletimes) {        if(NULL==mshakeanimation) {mshakeanimation=NewTranslateanimation (0, 10, 0, 0); Mshakeanimation.setinterpolator (NewCycleinterpolator (Cycletimes));//set the speed, cycleinterpolator some sort of mathematical curve, that is, the rate of shaking is curvedMshakeanimation.setduration (1500); Mshakeanimation.setrepeatmode (animation.reverse);//set the reverse direction of execution} tv_curmoney.startanimation (mshakeanimation); Tv_curmoney is a TextView control}

3. Set the Zoom animation
/***         /final scaleanimation animation =new scaleanimation (0.0f, 1.0f, 0.0f, 1.0f, Animation.relative_to_self, 0.5f, animation.relative_to_self, 0.5f);         Animation.setduration (2000); //         Iv_go_rank is a ImageView control

Introduction to Rates:

Defining interpolator in an XML file

Android:interpolator= "@android: Anim/accelerate_interpolator"
Android:shareinterpolator= "true"

So all the animation share a interpolator.

Set the following code in code

Anim.setinterpolator (New Accelerateinterpolator ());

When you pass in new one animationset true, all animation share the interpolator.




Android Background Code settings 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.