Here's what I want:
- An image is shown.
- The image fades out from 100 to 0.
- The image moves from 0 to 100 (x axis) while being hidden.
- The image fades in from 0 to 100.
Here's what I got but something else is happening: The image fades out, but then appears and moves, then the image disappears for a moment then fades in from 0 to 100 (this last one I understand).
public void MyAnimation() {
HideImageAnimation = new AlphaAnimation(1.0f, 0.0f);
HideImageAnimation.setDuration(1000);
HideImageAnimation.setFillAfter(true);
HideImageAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation arg0) {
Log.i("ANIM", "Hidden, move image");
i.setVisibility(View.GONE);
i.startAnimation(MoveImageAnimation);
}
@Override
public void onAnimationRepeat(Animation arg0) {
}
@Override
public void onAnimationStart(Animation arg0) {
}
});
ShowImageAnimation = new AlphaAnimation(0.0f, 1.0f);
ShowImageAnimation.setDuration(1000);
ShowImageAnimation.setFillAfter(true);
ShowImageAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation arg0) {
Log.i("ANIM", "Showed, hide image");
}
@Override
public void onAnimationRepeat(Animation arg0) {
}
@Override
public void onAnimationStart(Animation arg0) {
}
});
MoveImageAnimation = new TranslateAnimation(0, 100, 0, 0);
MoveImageAnimation.setDuration(1000);
MoveImageAnimation.setFillAfter(true);
MoveImageAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) {
i.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(Animation arg0) {
}
@Override
public void onAnimationEnd(Animation arg0) {
Log.i("ANIM", "Moved, show image");
i.startAnimation(ShowImageAnimation);
i.setVisibility(View.VISIBLE);
}
});
i.startAnimation(HideImageAnimation);
}
Aucun commentaire:
Enregistrer un commentaire