[Android] frame animation and gap animation
Display a picture frame by frame and connect it into animation
Create a xxx.xml file in the RES / drawable / directory
Add the < animation list > node and set whether to cycle Android: oneshot: "false"
Add an entry < item > node and set the resource Android: drawable = "@ drawable / xxx"
Set the execution time, Android: duration = "100"
Add corresponding pictures frame by frame
Get the ImageView object through findviewbyid()
Call setbackgroundresource() of ImageView object to set background resource. Parameter: resource file
Call the getbackground () method of the ImageView object to get the animationdrawable object
The getbackground () method is executed asynchronously in a separate thread. Therefore, sometimes the following code cannot be played. It is recommended to put it in the button click event or screen touch event
Call the animationdrawable object start() method to start playback
Tweet animation
transparency
Get alphaanimation object, new alphaanimation(), parameters: from 0.0F transparency to 1.0F transparency
Setduration() method of alphaanimation object to set the execution time
Call the startanimation () method of the view object. Parameter: alphaanimation object
zoom
Get scaleanimation object, new scaleanimation(), parameters:
Original width, width after change, original height, height after change, animation.relax_ TO_ Self, o.5f x centered, animation.relax_ TO_ Self, 0.5f y centered
Call the startanimation () method of the view object. Parameter: scaleanimation object
rotate
Get the rotateanimation object, new rotateanimation(), parameters:
Select from 0, rotate 360 degrees, and rotate the center animation.relax_ TO_ Self, o.5f x center, rotation center animation.relax_ TO_ Self, o.5f x centered
Call the startanimation () method of the view object. Parameter: rotateanimation object
translation
Get the translateanimation object, new translateanimation(), parameters:
Relative to parent form animation.relax_ TO_ PARENT,0.0f
Relative to parent form animation.relax_ TO_ PARENT,1.0f
Relative to parent form animation.relax_ TO_ PARENT, 0.0f
Relative to parent form animation.relax_ TO_ PARENT, 1.0f
Call the startanimation () method of the view object. Parameter: translateanimation object
Composite animation
Get the animationset object and new it
Get multiple animation objects above
Call the addanimation () method of the animationset object to add the animation. Parameter: Animation
Just add it many times
Call the startanimation () method of the view object. Parameters: animationset object