Animate ImageView from alpha 0 to 1

后端 未结 3 977
一向
一向 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条回答
  •  闹比i
    闹比i (楼主)
    2021-01-27 22:02

    In MainActivity.java add

    public void blink(View view) {
            ImageView image = (ImageView) findViewById(R.id.imageView);
            Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink);
            image.startAnimation(animation1);
        }
    

    Create file named blink.xml in res>anim folder and add this code

    
    
        
    
    

    And make sure that onClick function on button is named blink

提交回复
热议问题