「左にスライドアウト」アニメーションを作成します。次に、新しいビューのアニメーションを調整して、アニメーションが開始されたら、別のアニメーションを別のビューに適用して開始します。例えば、
Animation animation = AnimationUtils.loadAnimation(context,
R.anim.slide_in_right);
animation.setDuration(TIME);
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO - Set and start other animation here
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
});
view.startAnimation(animation);
[編集]
// First, define and infalte the view that will be incoming
View upcomingView = inflater.inflate(...);
// Next, we'll set the animation up
Animation animation = AnimationUtils.loadAnimation(context,
R.anim.slide_in_right);
animation.setDuration(TIME);
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
Animation outAnimation = AnimationUtils.loadAnimation(context,
R.anim.slide_out_left);
upcomingView.startAnimation(outAnimation);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
});
currentView.startAnimation(animation); // This will start the animation defined above, which will also set and start the animation for the incoming object