How to set button click effect in Android?

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

    For all the views

    android:background="?android:attr/selectableItemBackground"

    But for cardview which has elevation use

    android:foreground="?android:attr/selectableItemBackground"

    For Circular click effect as in toolbar

    android:background="?android:attr/actionBarItemBackground"
    

    Also you need to set

     android:clickable="true"
     android:focusable="true"
    

提交回复
热议问题