How to set button click effect in Android?

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

    You can simply use foreground for your View to achieve clickable effect:

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


    For use with dark theme add also theme to your layout (to clickable effect be clear):

    android:theme="@android:style/ThemeOverlay.Material.Dark"
    

提交回复
热议问题