在android中没有转换的动画后运行动画

时间:2012-03-13 09:45:38

标签: android android-animation

我有一个逐帧动画,我希望在按钮点击时启动另一个动画,平滑过渡(风格“tom the cat”)。

这是第一个动画的代码:

AnimationDrawable animation;

 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);

   animation = new AnimationDrawable();
   animation.addFrame(getResources().getDrawable(R.drawable.m1), 100);
   animation.addFrame(getResources().getDrawable(R.drawable.m2), 100);
   animation.addFrame(getResources().getDrawable(R.drawable.m3), 100);
   animation.addFrame(getResources().getDrawable(R.drawable.m4), 100);
   animation.addFrame(getResources().getDrawable(R.drawable.m5), 100);
   animation.addFrame(getResources().getDrawable(R.drawable.m6), 100);
   animation.addFrame(getResources().getDrawable(R.drawable.m7), 100);
   animation.addFrame(getResources().getDrawable(R.drawable.m8), 100);
   animation.addFrame(getResources().getDrawable(R.drawable.m9), 100);
   animation.addFrame(getResources().getDrawable(R.drawable.m10), 100);
   animation.addFrame(getResources().getDrawable(R.drawable.m11), 100);
   animation.addFrame(getResources().getDrawable(R.drawable.m12), 100);
   animation.setOneShot(false);

   ImageView imageAnim =  (ImageView) findViewById(R.id.img);
   imageAnim.setBackgroundDrawable(animation);

   // run the start() method later on the UI thread
   imageAnim.post(new Starter());

}

class Starter implements Runnable {

   public void run() {
       animation.start();        
   }

}

0 个答案:

没有答案