1

I guess this is pretty simple question but somehow I cannot figure it out.

I am animating couple of .png file from drawable folder, it is working fine as they are animated and stopped as required. What I am trying from previous three hours is that I want to hide the imageview once the animation is stopped. This is the simple code i am using

animImageView = (ImageView) findViewById(R.id.iv_animation);
    animImageView.setBackgroundResource(R.drawable.anim);
    animImageView.post(new Runnable() {
        @Override
        public void run() {
            visiblity = false;
            frameAnimation =
                    (AnimationDrawable) animImageView.getBackground();

            frameAnimation.start();
            frameAnimation.setOneShot(true);
            //animImageView.setVisibility(View.INVISIBLE);


        }
    });

Even tried the removeCallBack() methods on imageview but its not working. Can somebody please guide me what I am doing wrong or what I need to do to overcome this.

Thanks.

Umair
  • 438
  • 1
  • 8
  • 19
  • Using this [http://stackoverflow.com/questions/2214735/android-animationdrawable-and-knowing-when-animation-ends], i managed to hide the imageview – Umair Jul 24 '16 at 11:23

2 Answers2

1

There is no finish listener for AnimationDrawable. Try this approach, https://stackoverflow.com/a/15856260/1972597

Community
  • 1
  • 1
Tony
  • 2,242
  • 22
  • 33
  • With this approach you suggested, how could I animate different images from my drawable folder ? – Umair Jul 24 '16 at 10:52
0

What you can do is after your animation is over, just call

iv.setVisibility(View.GONE);

there is an animation listener availale. So you can use it for Animation Utils

Devam03
  • 141
  • 1
  • 7
  • I have tried this approach already, but it just hide the image view before the animations get started ! – Umair Jul 24 '16 at 10:41