Home > Software engineering >  Set imageview visible in original position while translate animating
Set imageview visible in original position while translate animating

Time:07-12

When an imageview is animating with translate animation the imageview appears to moves from the position (although it's still in its actual position) and the imageview original position will be hidden until the translate animation is completed then its visible again. So what I want is to set the animation visible on the original position while animating.

animation.setDuration(1000);
animation.setFillAfter(true);
myImage.startAnimation(animation);

CodePudding user response:

try this code...this code for transition top animate...

public static Animation myTransInTop(final View NewView, long startOffset, int duration, int FromY) {
    Animation translateAnimation = new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, FromY,
            Animation.RELATIVE_TO_SELF, 0);
    translateAnimation.setDuration(duration);
    translateAnimation.setStartOffset(startOffset);
    translateAnimation.setFillEnabled(true);
    translateAnimation.setFillAfter(true);
    translateAnimation.setInterpolator(new OvershootInterpolator());
    NewView.startAnimation(translateAnimation);
    return translateAnimation;
}
  • Related