I believe the accepted answer should be:
android:background="?attr/selectableItemBackground"
This is the same as @lory105's answer but it uses the support library for maximum compatibility (the android:
equivalent is only available for API >= 11)
Setting the background to "@null"
will make the button have no effect when clicked. This will be a better choice.
style="?android:attr/borderlessButtonStyle"
Later I found that using
android:background="?android:attr/selectableItemBackground"
is also a good solution. And you can inherit this attribute in your own style.
Don't use null or transparent if you need a click animation. Better:
//Rectangular click animation
android:background="?attr/selectableItemBackground"
//Rounded click animation
android:background="?attr/selectableItemBackgroundBorderless"
Use ImageView
... it have transparent background by default...
Set the background of the ImageButton as @null in XML
<ImageButton android:id="@+id/previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/media_skip_backward"
android:background="@null"></ImageButton>
It's android:background="@android:color/transparent"
<ImageButton
android:id="@+id/imageButton"
android:src="@android:drawable/ic_menu_delete"
android:background="@android:color/transparent"
/>