如何在DrawableAnimation android中隐藏动画

如何在DrawableAnimation android中隐藏动画,android,animation,animationdrawable,Android,Animation,Animationdrawable,我写了一个类似progressdialog的动画。我想在单击按钮时停止并隐藏动画。这是我的密码 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); img = (ImageView)findViewById(R.id.imageView1); startB

我写了一个类似progressdialog的动画。我想在单击按钮时停止并隐藏动画。这是我的密码

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    img = (ImageView)findViewById(R.id.imageView1);

    startButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
             img.setBackgroundResource(R.drawable.animitems);
             myAnim = (AnimationDrawable)img.getBackground();
             if(videoView.isPlaying()){
                 videoView.pause();
                 myAnim.stop();
                 myAnim.setVisible(false, true);
                 startButton.setBackgroundResource(R.drawable.andplaybtn);
             }else{
                 startButton.setBackgroundResource(R.drawable.andstopbtn);
                 myAnim.start();
                 videoView.start();
             }
        }
    });
您可以看到,我使用了DrawableAnimation类。但我不能在启动时隐藏动画。如何做到这一点?谢谢你的帮助