[Android] frame animations and tweened animations

Source: Internet
Author: User

Display a picture frames by frame, and connect them as animations

Under the res/drawable/ directory, create a xxx.xml file

Add <animation-list> node, set whether to loop Android:oneshot:"false"

Add Entries <item> nodes, set resource android:drawable="@drawable/xxx"

Set execution time,android:duration="100"

Add the corresponding picture frame by frames

Gets the ImageView object, via Findviewbyid ()

Call the ImageView object's setbackgroundresource () to set the background resource, parameter: resource file

Call the Getbackground () method of the ImageView object to get to the animationdrawable Object

The Getbackground () method is executed asynchronously in a separate thread, so sometimes the following code is not playable, it is recommended to be placed in a button click event, or in a screen touch event

Call the animationdrawable object start () method to start playback

Tween Animation

Transparency

Gets the alphaanimation object,new Alphaanimation (), Parameters: from 0.0f transparency, to 1.0f Transparency

The setduration () method of the Alphaanimation object , setting the execution time

Call the startanimation () method of the View object , Parameter:alphaanimation Object

Scaling

Get scaleanimation object,new Scaleanimation (), Parameters:

Original width, wide after change, original high, high after change,animation.relative_to_self,o.5f x to center, Animation.relative_to_self,0.5f y with center

Call the startanimation () method of the View object , Parameter:scaleanimation Object

Rotating

Get rotateanimation object,new Rotateanimation (), Parameters:

Choose from 0 , rotate the degree of rotation , rotate center animation.relative_to_self,o.5f x to center, rotate center animation.relative_to_self,o.5f x to center

Call the startanimation () method of the View object , Parameter:rotateanimation Object

Translation

Get translateanimation object,new Translateanimation (), Parameters:

Relative to parent form animation.relative_to_parent,0.0f

Relative to parent form animation.relative_to_parent,1.0f

Relative to parent form animation.relative_to_parent, 0.0f

Relative to parent form animation.relative_to_parent, 1.0f

Call the startanimation () method of the View object , Parameter:translateanimation Object

Combo Animations

Get animationset object,new out

Get to multiple animated objects above

Call the addanimation () method of the animationset object to Add the animation, Parameters: Animation

You can add it multiple times.

Call the startanimation () method of the View object , Parameter:animationset Object

[Android] frame animations and tweened animations

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.