1.Frame Animation 逐帧动画

加载动画/渐变动画等,用途也是挺多的。

资料1
资料2


//false 一直重复执行,true执行一次。
    
    
    
    
    

ImageView mImageViewFilling = (ImageView) findViewById(R.id.imageview_animation_list_filling);
((AnimationDrawable) mImageViewFilling.getBackground()).start();
  代码中添加
  rocketAnimation = new AnimationDrawable();
  rocketAnimation.addFrame(getResources().getDrawable(R.drawable.rocket_thrust1, 200);
  rocketAnimation.addFrame(getResources().getDrawable(R.drawable.rocket_thrust2, 200);
  rocketAnimation.addFrame(getResources().getDrawable(R.drawable.rocket_thrust3, 200);
  rocketImage.setBackground(rocketAnimation);  
  • 需要注意的是,动画的启动需要在view和window建立连接后才可以绘制,比如上面代码是在用户触摸后启动。如果我们需要打开界面就启动动画的话,则可以在Activity的onWindowFocusChanged()方法中启动。
Animated-Selector 21以上,需要适配。

你可能感兴趣的:(1.Frame Animation 逐帧动画)