1 to realize fade animation
Implementing in a program can be done in the following ways
View view = new view (context);//Animation view
alphaanimation AA = new Alphaanimation (1.0f, 0.0f);//Create a Alphaanimation object , the gradient
sets the duration Aa.setfillafter (true) from the 1->0 aa.setduration (1500);
//sets the last state of the view, because it is from 1->0, So the final is the vanishing state (and finally the view is not visible)
viewstartanimation (AA);/Start animation
Of course, the configuration file can also be implemented
First create a new Anim folder in the Res directory, and then create a new XML file under Anim folder Gradually.xml
The XML file primarily defines how the gradient is implemented
<?xml version= "1.0" encoding= "Utf-8"?> <set xmlns:android=
"http://schemas.android.com/apk/res/" Android ">
<alpha
android:fromalpha=" 0.0 "
android:toalpha=" 1.0 "
android:duration=" 2000 "
/>
Alpha represents transparency, 0.0 is completely transparent, 1.0 is completely opaque, duration refers to excess time
Animation Animation = animationutils.loadanimation (context, r.anim.gradually);
View.setfillafter (TRUE)//keep the last gradient state
view.startanimation (animation);//Start animation
2 realize the effect of fading
View view = new view (context);//Animation view
alphaanimation AA = new Alphaanimation (0.0f, 1.0f);//Create a Alphaanimation object , the gradient
sets the duration Aa.setfillafter (true) from the 1->0 aa.setduration (1500);
//sets the final animation effect, which is the display status (the last view can be seen)
Viewstartanimation (AA);//Start animation
The actual implementation of the configuration file is similar to the above.
The above is a small set of Android to introduce the realization of the game in the fade and fade animation effect of all content, I hope to help everyone, if you have any questions welcome to my message, small series will promptly reply to everyone!