Frame-by-frame animation: Animation
Frame-by-frame animation
Xml file configuration method
* Oneshot: the number of playback times configured. true: Wireless loop fale: playback only once
- Item Single Image Option
- Drawable Image
- Duration playback time
Call in code
* Method 1: AnimationDrawable drawable = (AnimationDrawable) getResources (). getDrawable (R. drawable. shot); ivView. setBackground (animationDrawable1); drawble. start (); * method ivView. setBackgroundResource (R. drawable. shot); AnimationDrawable drawable = (AnimationDrawable) ivView. getBackground (); drawable. start ();
Directly implement animations in code without Layout
AnimationDrawable drawable = new AnimationDrawable();drawable.addFrame(getResources().getDrawable(R.drawable.img00),100);drawable.addFrame(getResources().getDrawable(R.drawable.img06),100);drawable.addFrame(getResources().getDrawable(R.drawable.img07),100);ivView.setBackground(drawable);drawable.start();
Compensation Animation
* Pan Animation
* Scaling Animation
* Rotating Animation
* Transparency Animation
The following attributes are available for all the above four animations:
Android: duration = "3000" // animation duration (MS), must be set, animation has effect
Android: startOffset = "1000" // animation delay start time (MS)
Android: fillBefore = "true" // After the animation is played, whether the view will remain in the starting state of the animation. The default value is true.
Android: fillAfter = "false" // After the animation is played, whether the view stays at the end of the animation. The default value is false.
Android: fillEnabled = "true" // whether to apply the fillBefore value. This parameter has no effect on the fillAfter value. The default value is true.
Android: repeatMode = "restart" // select the Animation Mode for repeated playback. restart indicates positive replay, and reverse indicates reverse playback. The default value is restart. |
Android: repeatCount = "0" // Number of replay times (so the number of playback times of the animation = replay times + 1). If it is infinite, it will be infinitely repeated.
Android: interpolator = @ [package:] anim/interpolator_resource // interpolation tool, which affects the playing speed of the animation.
Pan Animation
The translation animation achieves its own jitter Effect
Animation shake = new TranslateAnimation (Animation. RELATIVETOSELF, 0f, Animation. RELATIVETOSELF, 0.01f, Animation. RELATIVETOSELF, 0f, Animation. RELATIVETOSELF, 0f );
Shake. setDuration (1000 );
Shake. setInterpolator (new CycleInterpolator (10 ));
FindViewById (R. id. btn_four). startAnimation (shake );
Zoom Animation
Rotating Animation
Transparency Animation
Animation set