Animations in Android

Source: Internet
Author: User

Two kinds of animations

View Animation Properties Animation (you can also use XML to describe animations)

View 4 animations

补间动画                渐变  AlphaAnimation                      缩放  ScaleAnimation                      平移 TranslateAnimation                       旋转 RotateAnimation                                 逐帧动画    轮播帧动画矩阵动画    SVG失量动画

View Properties

property to guide the package before 3.0

It is two different 1.View animation can do, property animation can do.

         2.View动画并没有真正改变View的位置,属性动画,真正改变了View的位置
 

1.view Animation

Here is the example code we used to do the interface jump

It allows the interface to rotate, scale, and gradient

Then play with the animation collection

public class Splashactivity extends Activity {private relativelayout rlroot;        @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);        Setcontentview (R.layout.activity_splash);        Rlroot = (relativelayout) Findviewbyid (r.id.rl_root); Rotary rotateanimation animrotate = new Rotateanimation (0, Animation.relative_to_self, 0.5f, Anim ation. Relative_to_self, 0.5f);//Rotate 360 degrees Animrotate.setduration (1000) based on its center point;//Animation time Animrotate.setfil Lafter (TRUE);//Hold the state of the end of the animation//zoom scaleanimation Animscale = new Scaleanimation (0, 1, 0, 1, Anim ation.        Relative_to_self, 0.5f, Animation.relative_to_self, 0.5f);        Animscale.setduration (1000);        Animscale.setfillafter (TRUE);        Gradient alphaanimation Animalpha = new Alphaanimation (0, 1);        Animalpha.setduration (2000);        Animalpha.setfillafter (TRUE);       Animation collection Animationset set = new Animationset (false);        Set.addanimation (animrotate);        Set.addanimation (Animscale);        Set.addanimation (Animalpha);        Start animation rlroot.startanimation (set); Set.setanimationlistener (New Animationlistener () {@Override public void Onanimationstart (Animation            Animation) {} @Override public void Onanimationrepeat (animation animation) { }//End of animation @Override public void Onanimationend (Animation Animation) {//judged to have The boot page has not been shown Boolean isguideshow = Prefutils.getboolean (Getapplicationcontext (), "Is_gu                Ide_show ", false);                            if (!isguideshow) {//Jump to Novice boot page startactivity (new Intent (Getapplicationcontext (),                Guideactivity.class)); } else {//jumps to the main page startactivity (new Intent (GetapPlicationcontext (), mainactivity.class));            } finish ();    }        }); }

}

2. Property animations

An official API to implement animations

We are doing a few page jumps to use

Overridependingtransiton (Enteranim,exitanim); Implement out, come in the animation

Animations in 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.