使用animation-list標(biāo)簽分組,每一個(gè)item標(biāo)簽集合,定義要顯示的圖片,指定他顯示的時(shí)間,顧名思義,就是一幀一幀的播放,達(dá)到動(dòng)畫片一樣的效果
xml文件要放到drawable下,下圖為xml文件R.drawable.animation:
fram_animation.png
具體使用代碼如下:
AnimationDrawable animationDrawable
animationIV = (ImageView) findViewById(R.id.animationIV);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
animationIV.setImageResource(R.drawable.animation);
animationDrawable = (AnimationDrawable) animationIV.getDrawable();
animationDrawable.start();
}
}); ```