How to set button click effect in Android?

后端 未结 14 2368
佛祖请我去吃肉
佛祖请我去吃肉 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 01:53

    Use RippleDrawable for Material Design state pressed/clicked effect.

    In order to achieve this, create ripple item as an .xml under /drawable folder and use it in android:background for any views.

    • Effect for icon pressed/clicked, use circular ripple effect, for example:

    • Effect for view clicked with rectangle boundary, we can add ripple over the existing drawable like bellow:

提交回复
热议问题