我正在尝试创建一个可绘制的动画,它只具有两个帧并在屏幕上循环。
但是,由于某种原因,我的 Animationdrawable 甚至没有做一轮,只是显示了第一帧,更不用说循环了......
这是我的代码:
Handler handler = new Handler();
AnimationDrawable mouseani = new AnimationDrawable();
ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Drawable mouse1 = getResources().getDrawable(R.drawable.mouse_for_use);
Drawable mouse2 = getResources().getDrawable(R.drawable.mouse_for_use_2);
mouseani.addFrame(mouse1, 500);
mouseani.addFrame(mouse2, 500);
img = (ImageView) findViewById(R.id.imgView);
img.setBackgroundDrawable(mouseani);
mouseani.setCallback(img);
mouseani.setVisible(true, true);
mouseani.start();
mouseani.stop();
}
谢谢!