在Activity的onCreate()或者onStart() ,调用AnimationDrawable.start()方法,动画是不会运行的
解决办法: private Handler handler = new Handler(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.loading); ImageView line = (ImageView) findViewById(R.id.loading_line); handler.postDelayed(new Runnable() { public void run() { AnimationDrawable frameAnimation = (AnimationDrawable) line.getBackground(); frameAnimation.start(); } }, 50); } } |