AnimationDrawable animation = new AnimationDrawable();
animation.addFrame(getResources().getDrawable(R.drawable.a1), 1000);
animation.addFrame(getResources().getDrawable(R.drawable.a2), 1000);
animation.addFrame(getResources().getDrawable(R.drawable.a3), 1000);
animation.addFrame(getResources().getDrawable(R.drawable.a4), 1000);
animation.addFrame(getResources().getDrawable(R.drawable.a5), 1000);
animation.addFrame(getResources().getDrawable(R.drawable.a6), 1000);
animation.addFrame(getResources().getDrawable(R.drawable.a7), 1000);
animation.addFrame(getResources().getDrawable(R.drawable.a8), 1000);
animation.addFrame(getResources().getDrawable(R.drawable.a9), 1000);
animation.addFrame(getResources().getDrawable(R.drawable.a10), 1000);
animation.setOneShot(true);
sayac = (ImageView) findViewById(R.id.sayac);
sayac.setImageDrawable(animation);
animation.start();
// play the animation when i push the play button
play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
// pause the animation when i push pause button...
pause.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
我想暂停并恢复AnimationDrawable
。但我不能。我怎么能这样做?
或者我可以使用ObjectAnimator
或其他人制作相同的动画吗?
如果我可以使用ObjectAnimator
执行相同的动画,我该怎么办?有没有教训或例子?