Transparency control animation effect alpha
XML definition
<? Xml version = "1.0" encoding = "UTF-8"?>
<Set xmlns: android = "http://schemas.android.com/apk/res/android">
<Alpha
Android: fromalphi = "0.1"
Android: toAlpha = "1.0"
Android: duration= "3000"
/>
</Set>
The toAlpha attribute is the transparency floating point type when the animation ends.
(0.0 indicates completely transparent. 1.0 indicates completely opaque)
The duration attribute is the animation duration (in milliseconds)
How does Java call animations defined in XML? The Code is as follows:
Public static Animation loadAnimation (Context context, int id)
// The first parameter Context is the Context of the program
// The second parameter id is the reference of the animated XML file.
MyAnimation = AnimationUtils. loadAnimation (this, R. anim. my_action );
// Use the static method loadAnimation () of the AnimationUtils class to load the animation XML file in XML
JavaCode Definition
AlphaAnimation
Private Animation myAnimation_Alpha; // defines the Animation.
MyAnimation_Alpha = new AlphaAnimation (0.1f, 1.0f); // initialize the animation object parameter 1. Transparency parameter 2. Transparency at animation end
MyAnimation_Alpha.setDuration (5000); // set the duration to 5000 milliseconds.