简体   繁体   中英

Android textView animation at the same time

I want to be able to do this: the TextView to change its size (to get bigger) and to change its alpha value (from invisible to become visible). All of this using Animation and have this changes happen at the same time. For that purpose I come up with this code:

  AnimationSet set = new AnimationSet(true);
  Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(2000);
    animation.setStartOffset(300);
    animation.setFillAfter(true);
    set.addAnimation(animation);

    animation = new ScaleAnimation(1.0f, 2.0f, 1.0f, 2.0f);
    animation.setDuration(2000);
    animation.setStartOffset(300);
    animation.setFillAfter(true);
    set.addAnimation(animation);

    text.startAnimation(set);

The problem with this is that I want this transformation to remain. But the textView keeps coming back to its original size at the end. (But it remains visible - alpha = 1.0f). Am I doing something wrong? Please, if someone knows how can I make this work, help me. Thank u in advance!

I've found an answer for the problem five minutes after actually posting it. You should not define setFillAfter for the individual animations that you define in the animation set. You should only define setFillAfter ON the animation set itself

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM