How to set button click effect in Android?

后端 未结 14 2369
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 01:29

In Android, when I set background image to Button, I can not see any effect on button.

I need some effect on button so user can recognize that button is clicked.

14条回答
  •  攒了一身酷
    2020-11-28 02:01

    Create bounce.xml file for animation

    
    
    
        
    
    
    

    Add this line in onClick to initialize

    final Animation myAnim = AnimationUtils.loadAnimation(this, R.anim.bounce); button.startAnimation(myAnim);

    You get the shrink effect in a button click.

提交回复
热议问题