Statement
You are welcome to repost, but please keep the original source of the article :)
Focus: http://www.focuser.org
Link: http://www.focuser.org /? P = 267
In
Android
Medium,
Animation
Animation effects can be implemented in two ways, one is
Tweened
Animation
Gradient animation, the other is
Frame
By Frame Animation
Screen conversion animation.
Tweened Animation
There are two types of gradient Animation:
1. Alpha
Gradient transparency animation effect
2. Scale
Gradient scaling animation effect
Frame by frame animation
There are two types of screen conversion Animation:
1. Translate
Animation Effect
2. Rotate
Animation effects of screen transfer and Rotation
In
Res
Create a folder
Anim
And create
Animation. xml
File:
<? XML version = "1.0"
Encoding = "UTF-8"?>
<Set
Xmlns: Android = "http://schemas.android.com/apk/res/android">
<Translate
Android: fromxdelta = "0"
//
When the animation is set to start
X
Coordinates
Android: toxdelta = "-100% P"
//
Set the animation End Time
X
Coordinates
Android: duration= "300"
//
Set the animation duration
300
Millisecond
>
</Translate>
<Alpha
Android: fromalphi = "1.0"
//
Sets the transparency at the beginning of the animation.
1.0
Indicates opacity
Android: toalpha = "0.0"
//
Sets the transparency at the beginning of the animation.
0.0
Completely transparent
Android: duration= "300"
//
Set the animation duration
300
Millisecond
/>
<Scale
Android: interpolator ="
//
Set the animation Reader
@ Android: anim/accelerate_decelerate_interpolator"
Android: fromxscale = "0.0"
//
When the animation is set to start
X
Scaling length on coordinates
Android: toxscale = "1.4"
//
Set the animation End Time
X
Scaling length on coordinates
Android: fromyscale = "0.0"
//
When the animation is set to start
Y
Scaling length on coordinates
Android: toyscale = "1.4"
//
When the animation is set to start
Y
Scaling length on coordinates
Android: Required Tx = "50%"
//
Set the animation to
X
Coordinates
Android: Ty = "50%"
//
Set the animation to
Y
Coordinates
Android: fillafter = "false"
//
This animation is used before the animation ends.
Android: Duration = "700 "//
Set the animation duration
/>
<Rotate
Android: interpolator =
//
Set the animation Reader
"@ Android: anim/accelerate_decelerate_interpolator"
Android: fromdegrees = "0"
//
Set the animation start angle
Android: todegrees = "+ 350"
//
Sets the rotation angle at the animation end.
Android: Required Tx = "50%"
//
Set the animation to
X
Coordinates
Android: Ty = "50%"
//
Set the animation to
Y
Coordinates
Android: duration= "3000"
//
Set the animation duration
/>
</Set>
Exploitation
Animationutils. loadanimation
Load an animation
Animation animation;
Animation = animationutils. loadanimation (this,
R. anim. animation );
Then, you can use
Startanimation ()
Method.
//
Compile an animation object and obtain the Custom Animation style.
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 );
//
Set
Spinner
Sets the visibility to invisible.
V. setvisibility (view. Invisible );
Return
False;
}
});
Link: http://www.focuser.org /? P = 267