Animate ImageView from alpha 0 to 1

后端 未结 3 975
一向
一向 2021-01-27 21:21

I have an imageView that I want to start as invisible. After a certain button is clicked, I want to animate the Image into view and then I want it to remain at alpha 1. How do I

3条回答
  •  鱼传尺愫
    2021-01-27 21:52

    Try to make your ImageView invisible in xml:

    
    

    Then, by adding an AnimationListener, make it visible in onAnimationStart:

    ...
    animation1.setFillAfter(true);
    animation1.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            // pass it visible before starting the animation
            tokenBtn.setVisibility(View.VISIBLE);
        }
    
        @Override
        public void onAnimationRepeat(Animation animation) {    }
        @Override
        public void onAnimationEnd(Animation animation) {    }
    });
    // finally, start the animation
    tokenBtn.startAnimation(animation1);
    

提交回复
热议问题