问题
Well this is the code I use to animate the view so that old image disappears (black background) and new one slides in from outside (from left to right).
this.imgView.setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_right));
this.imgView.setImageResource(imageArray[next]);
How do I make it that old image slides out of the screen before new one shows up. Would be great if both were visible but I guess that would require 2 views to switch, so for now I could stick to one on screen at a time.
回答1:
Use ViewFlipper to switch between two ImageView:s in the same Activity and set a slide animation to the ViewFlipper.
Set correct image resource in the next and previous image view before calling showNext() and showPrevious().
回答2:
You can do this by using TranslateAnimation. apply the following code and see what happend
TranslateAnimation left = new TranslateAnimation(-480, 10, 0, 10);
left.setDuration(2000);
left.setRepeatCount( 1 );
view=(ImageView)findViewById( R.id.iv);
view.startAnimation(left);
Create your own TranslateAnimation and apply accordingly
来源:https://stackoverflow.com/questions/4689220/android-animation-while-switching-imageview-resource