Search code examples
javaandroidxmlimagebutton

Transparent background in ImageButton with ripple effect?


I want to programmatically remove the grey background in ImageButton. I tried many method of removing it like -

imageButton.setBackgroundDrawable(null);

but on implementing them, I don't get the ripple effect on the ImageButton on touch. (No highlighting on touch).

Is there any way to remove the background but preserve the ripple effect or highlight.


Solution

  • If android:background="?attr/selectableItemBackground" this works than I believe this answer should solve your problem:

    https://stackoverflow.com/a/28087443/2534007