How to do a fadein of an image on an Android Activity screen?

后端 未结 4 1529
别跟我提以往
别跟我提以往 2020-12-02 07:45

I\'d like to display a photo on an Android Activity screen with doing gradual and continual fade-in from pale monotone sepia to the final full color. I know how to do it on

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-02 08:01

    I wanted an image to fade (and then disappear) once clicked from full opacity to 0. Here is how I did it:

    Animation a = new AlphaAnimation(1.00f, 0.00f);
    
    a.setDuration(1000);
    a.setAnimationListener(new AnimationListener() {
    
        public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub
    
        }
    
        public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub
    
        }
    
        public void onAnimationEnd(Animation animation) {
            yourView.setVisibility(View.GONE);
    
        }
    });
    
    yourView.startAnimation(a);
    

提交回复
热议问题