Android Learning Notes-Tenth chapter animation

Source: Internet
Author: User

Tenth. Animations in Android

  1. Scenarios for animating: gif/flash/video

  2. The principle and three elements of animation:

    Principle: Several pictures, continuous fast switching.

    Three elements: multiple pictures, order, time interval

  3. Categories of animations:

    (1) frameanimation frame animation (drawable Animation)

    Implementation steps:

    A. Prepare several pictures

    B. Create a new Android XML file, where resource Type: drawable, Root Element:   animation-list

    C. Edit animation profile, set picture order and toggle Interval


    650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6D/17/wKiom1Vb_IzB4rgBAANOLGthVeE856.jpg "title=" Clipboard.png "width=" "height=" 278 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:600px;height:278px; "alt=" Wkiom1vb_izb4rgbaanolgthvee856.jpg "/>

    D. Getting animated objects


    650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6D/17/wKiom1Vb_SXyE2snAAFl3l_tBXg222.jpg "title=" Clipboard.png "alt=" Wkiom1vb_sxye2snaafl3l_tbxg222.jpg "/>

    E. Playing animations


    650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/12/wKioL1Vb_sOS_DkBAABDIj2ChPM694.jpg "title=" Clipboard.png "alt=" Wkiol1vb_sos_dkbaabdij2chpm694.jpg "/>

    A problem exists:

    A. More or larger pictures may cause outofmemoryerror

    B. On some devices (card/slow) may appear the animation does not display the problem

    Cause: The animation's playback and life cycle methods (OnStart ()/onresume ()) Order cannot be guaranteed

    Workaround: Play the animation over time, so that the animation plays after Onresume ()


    650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/12/wKioL1VcABijpiGQAAD6uHeh4Hc220.jpg "title=" Clipboard.png "width=" "height=" 161 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:600px;height:161px; "alt=" Wkiol1vcabijpigqaad6uheh4hc220.jpg "/>

    (2) tweenanimation (View Animation) motion Tween

    Principle: The system by changing the properties of the graphic, to supplement the transition process of the picture, produce animation effect

    Properties: Size/position/angle/transparency

    Cons: Just the effect transform on the view, the control itself does not change

    Implementation method:


    650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/17/wKiom1Vb_1HhqTT7AAEjQdipRjU843.jpg "title=" Clipboard.png "width=" "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:600px;height:88px; "alt=" Wkiom1vb_1hhqtt7aaejqdiprju843.jpg "/>

    Or


Create a new Android XML file,

Resource Type:tween Animation

Root element:alpha/scale/translate/rotate



650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6D/17/wKiom1Vb_3iyMuNIAAEWamo-LL0331.jpg "title=" Clipboard.png "alt=" Wkiom1vb_3iymuniaaewamo-ll0331.jpg "/>

Convert animation XML to animation object in code

Anim = animationutils.loadanimation(this, R.anim. Test_scale);

(3) Propertiesanimation Property animation

Pros: Really changed the state of the control

Problem: New features added after Android 3.x, need to be applied to 2.x

Solution: Open Source Project Nineoldandroid


Android Learning Notes-Tenth chapter 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.