Android highlight an imagebutton when clicked

后端 未结 5 985
执笔经年
执笔经年 2021-01-31 05:06

I am using an ImageButton. But I don get the highlight when clicked. I googled and many suggested to use selector where another image is displayed. Is there any way

5条回答
  •  情书的邮戳
    2021-01-31 05:32

    You can simply use android: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 make clickable effect clear):

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

提交回复
热议问题