制作animation类型的背景图片;
duration;持续事件;单位是毫秒;
为要设置动画的页面添加背景
找到控件并得到它的背景;
private boolean flag=true;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RelativeLayout view = findViewById(R.id.rl);
AnimationDrawable background = (AnimationDrawable) view.getBackground();
view.setonClickListener(new View.onClickListener() {
@Override
public void onClick(View v) {
if (flag){
background.start();
flag=false;
}else {
background.stop();
flag=true;
}



