I am working on game application and i use AnimationDrawable for image change.
but problem is i want imageview invisible when Animation is finish.so what should i do
for this.
My code is like this...
mAnimation = new AnimationDrawable();
mAnimation.addFrame(getResources().getDrawable(R.drawable.d5),50);
mAnimation.addFrame(getResources().getDrawable(R.drawable.d4),50);
mAnimation.addFrame(getResources().getDrawable(R.drawable.d3),50);
mAnimation.addFrame(getResources().getDrawable(R.drawable.d2),50);
mAnimation.addFrame(getResources().getDrawable(R.drawable.d1),150);
mAnimation.addFrame(getResources().getDrawable(R.drawable.d2),50);
mAnimation.addFrame(getResources().getDrawable(R.drawable.d3),50);
mAnimation.addFrame(getResources().getDrawable(R.drawable.d4),50);
mAnimation.addFrame(getResources().getDrawable(R.drawable.d5),50);
mAnimation.addFrame(getResources().getDrawable(R.drawable.new_transparent),50);
mAnimation.setOneShot(true);
mDogImage.setImageDrawable(mAnimation);
Thanks in advance.
There is no event or listener that will notify you.You just need to apply the trick
Use
mAnimation.getNumberOfFrames();to get total number of frames and since each frame will last long for 50ms.So your animation is supposed to end inmAnimation.getNumberOfFrames() * 50ms.For eg if you have 9 frames and each frame has duration of 50ms then your animation is going to end in 450ms.
So conclusion will be you will make your
ImageViewinvisible after 450ms once animation starts.