Display a picture frames by frame, and connect them as animations
Under the res/drawable/ directory, create a xxx.xml file
Add <animation-list> node, set whether to loop Android:oneshot:"false"
Add Entries <item> nodes, set resource android:drawable="@drawable/xxx"
Set execution time,android:duration="100"
Add the corresponding picture frame by frames
Gets the ImageView object, via Findviewbyid ()
Call the ImageView object's setbackgroundresource () to set the background resource, parameter: resource file
Call the Getbackground () method of the ImageView object to get to the animationdrawable Object
The Getbackground () method is executed asynchronously in a separate thread, so sometimes the following code is not playable, it is recommended to be placed in a button click event, or in a screen touch event
Call the animationdrawable object start () method to start playback
Tween Animation
Transparency
Gets the alphaanimation object,new Alphaanimation (), Parameters: from 0.0f transparency, to 1.0f Transparency
The setduration () method of the Alphaanimation object , setting the execution time
Call the startanimation () method of the View object , Parameter:alphaanimation Object
Scaling
Get scaleanimation object,new Scaleanimation (), Parameters:
Original width, wide after change, original high, high after change,animation.relative_to_self,o.5f x to center, Animation.relative_to_self,0.5f y with center
Call the startanimation () method of the View object , Parameter:scaleanimation Object
Rotating
Get rotateanimation object,new Rotateanimation (), Parameters:
Choose from 0 , rotate the degree of rotation , rotate center animation.relative_to_self,o.5f x to center, rotate center animation.relative_to_self,o.5f x to center
Call the startanimation () method of the View object , Parameter:rotateanimation Object
Translation
Get translateanimation object,new Translateanimation (), Parameters:
Relative to parent form animation.relative_to_parent,0.0f
Relative to parent form animation.relative_to_parent,1.0f
Relative to parent form animation.relative_to_parent, 0.0f
Relative to parent form animation.relative_to_parent, 1.0f
Call the startanimation () method of the View object , Parameter:translateanimation Object
Combo Animations
Get animationset object,new out
Get to multiple animated objects above
Call the addanimation () method of the animationset object to Add the animation, Parameters: Animation
You can add it multiple times.
Call the startanimation () method of the View object , Parameter:animationset Object
[Android] frame animations and tweened animations