Hello,
I'm trying to figure out how to animate in and out of Imageviews.
Basically I have a LinearLayout with an ImageView and a Button at the bottom. Everytime the button is pressed, onClick() is invoked and I do
image.setImageResource(imageArray[imageCounter]);
I simply change the image displayed on the ImageView by selecting different photos in the @drawable. Now I want to put an animation when these imageviews are changed (when button pressed). I used
inAnimation = AnimationUtils.makeInAnimation(this,true);
and in onClick() I do
image.setImageResource(imageArray[imageCounter]);
image.startAnimation(inAnimation);
This works fine too. The new image comes to the screen animated. But how can put an out animation too? It seems only one animation can be assigned with startAnimation().
What is the best way to animate an imageview OUT and then animate another imageview IN? Because I want to change the animation depending on the button pressed, I cannot use ViewFlipper. For example, if I press button_Anim1, current image will slideout from right and the new image will fade in. But if I press button_Anim2, current image will slideout from top and the new image will slidein from left. And so on.
I see that I cannot use two different
image.startAnimation()
in the onClick()
method to make the current image View.INVISIBLE
and then make the new image View.VISIBLE
.
Any suggestion is appreciated. Thank you.