android image view scale animation

后端 未结 1 495
我在风中等你
我在风中等你 2020-12-20 17:33

hi im wanting to know how to scale animate a logo and move its position?

i have an if statement that runs some checks and then when its done i want it to scale down

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-20 18:00

    You can do that by applying ScaleAnimation and TranslateAnimation together in AnimationSet

    // Scaling
    Animation scale = new ScaleAnimation(fromXscale, toXscale, fromYscale, toYscale, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    // 1 second duration
    scale.setDuration(1000);
    // Moving up
    Animation slideUp = new TranslateAnimation(fromX, toX, fromY, toY);
    // 1 second duration
    slideUp.setDuration(1000);
    // Animation set to join both scaling and moving
    AnimationSet animSet = new AnimationSet(true);
    animSet.setFillEnabled(true);
    animSet.addAnimation(scale);
    animSet.addAnimation(slideUp);
    // Launching animation set
    logo.startAnimation(animSet);
    

    0 讨论(0)
提交回复
热议问题