In Android, the Animation animation effect can be implemented in two ways, one is tweened Animation gradient animation, the other is frame
By Frame animation screen conversion animation, the next EoE to explain.
tweened Animation
The following two types of gradient animations are available:
1.alpha Gradient Transparency Animation effect
2.scale Gradient size Stretch animation effect
Frame
by frame animation
There are two types of picture conversion animations:
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"?> <Setxmlns:android= "Http://schemas.android.com/apk/res/android"> <TranslateAndroid:fromxdelta= "0"//Set the position of the x-coordinate when the animation starts Android:toxdelta= " -100%p"//Set the x-coordinate position at the end of the animation android:duration= "+"//Set the duration of the animation to 300 milliseconds> </Translate> <AlphaAndroid:fromalpha= "1.0"//Set the transparency at the beginning of the 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= "+"//Set the duration of the animation to 300 milliseconds/> < ScaleAndroid:interpolator= "//Set animation @android: Anim/accelerate_decelerate_interpolator"Android:fromxscale= "0.0"//Set the stretch length on the x-coordinate at the start of the animation Android:toxscale= "1.4"//Set the stretch length on the x-coordinate at the end of the animation Android:fromyscale= "0.0"//Set the stretch length on the y-coordinate at the start of the animation Android:toyscale= "1.4"//Set the stretch length on the y-coordinate at the start of the 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 is converted to apply android:duration before the end of the animation= "The "//Set the duration of the animation/> <RotateAndroid:interpolator= // set Animation "@android: Anim/accelerate_decelerate_interpolator" Android:fromdegrees= "0"//Set the angle at which the animation starts Android:todegrees= "+350"//Set the rotation angle at the end of the 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= " the"//Set the duration of the animation/> </Set>
Use Animationutils.loadanimation loads the animation.
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 stylesAnimation=animationutils.loadanimation ( This, r.anim.animation); Spinner.setontouchlistener (NewSpinner.ontouchlistener () {@Override Public BooleanOnTouch (View V, motionevent event) {//TODO auto-generated Method Stub//Run the animation animationv.startanimation (animation); //To set the visibility of a spinner to an invisible statev.setvisibility (view.invisible); return false; } });
Set animation animation effect in Android