帧动画在第一个activity中不能播放,必须要通过事件触发才行,解决:
package com.lik;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewTreeObserver.OnPreDrawListener;
import android.widget.ImageView;
public class lik extends Activity {
AnimationDrawable ad;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView iv = (ImageView) findViewById(R.id.animationImage);
iv.setBackgroundResource(R.drawable.frame_animation);
ad = (AnimationDrawable) iv.getBackground();
iv.getViewTreeObserver().addOnPreDrawListener(opdl);
}
OnPreDrawListener opdl=new OnPreDrawListener(){
@Override
public boolean onPreDraw() {
ad.start();
return true;
}
};
}