Frame-by-frame animation: Animation

Source: Internet
Author: User

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

 
             
      
      
      
      
      
  
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.