XML Settings Animation animation effect in Android

Source: Internet
Author: User

In Android, the Animation animation effect can be implemented in two ways, one is tweened Animation gradient animation, the other is the frame by frame Animation Picture conversion animation.

tweened Animation has the following two types of gradient animations:

1.alpha Gradient Transparency Animation effect

2.scale Gradient size Stretch animation effect

Frame by Frame animation screen conversion animations are available in the following two categories:

1.translate picture Conversion position Move animation effect

2.rotate Picture Transfer rotation animation effect

Create a new Anim folder under the Res folder and create a animation.xml file in it, as follows:

<?xml version= "1.0" encoding= "Utf-8"?>

<set

Xmlns:android= "Http://schemas.android.com/apk/res/android" >

<translate

Android:fromxdelta= "0"//Set the position of the x-coordinate at the start of the animation

Android:toxdelta= " -100%p"//Set the x-coordinate position at the end of the animation

android:duration= "300"//Set animation duration 300 ms

>

</translate>

<alpha

Android:fromalpha= "1.0"//Set transparency at start of Animation 1.0 for opaque

Android:toalpha= "0.0"//Set the transparency at the beginning of the animation 0.0 for full transparency

android:duration= "300"//Set animation duration 300 ms

/>

<scale

Android:interpolator= "//Set the animation to enter the device

@android: Anim/accelerate_decelerate_interpolator "

android:fromxscale= "0.0"//Set stretch length on x-coordinate at start of animation

android:toxscale= "1.4"//Set stretch length on x-coordinate at end of animation

android:fromyscale= "0.0"//Set stretch length on y-coordinate at start of animation

android:toyscale= "1.4"//Set stretch length on y-coordinate at start of animation

android:pivotx= "50%"//sets the position of the animation relative to the x-coordinate of the control

android:pivoty= "50%"//sets the position of the animation relative to the control's y-coordinate

Android:fillafter= "false"//The animation conversion begins before the end of the animation

Android:duration= "700"//Set the duration of the animation

/>

<rotate

android:interpolator=//Set animation in/out device

"@android: Anim/accelerate_decelerate_interpolator"

android:fromdegrees= "0"//Set the angle at which the animation starts

android:todegrees= "+350"//Set rotation angle at end of animation

android:pivotx= "50%"//sets the position of the animation relative to the x-coordinate of the control

android:pivoty= "50%"//sets the position of the animation relative to the control's y-coordinate

android:duration= "3000"//Set the duration of the animation

/>

</set>

Using Animationutils.loadanimation to load animations

Animation Animation;

Animation=animationutils.loadanimation (this, r.anim.animation);

You can then add it by using the Startanimation () method on the control that you want to animate.

Write animated objects and get custom animation styles

Animation=animationutils.loadanimation (this, r.anim.animation);

Spinner.setontouchlistener (New Spinner.ontouchlistener () {

@Override

public boolean OnTouch (View V, motionevent event) {

TODO auto-generated Method Stub

Run the animation animation

V.startanimation (animation);

To set the visibility of a spinner to an invisible state

V.setvisibility (view.invisible);

return false;

}

});

XML Settings Animation animation effect in Android

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.