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.
Create your own
RippleDrawable
and you need to use mask for the Ripple if you're going to use transparent background.If
android:background="?attr/selectableItemBackground"
this works than I believe this answer should solve your problem:https://stackoverflow.com/a/28087443/2534007
To have a transparent background with ripple effect, the background Drawable needs to be a rippleDrawable, which can be transparent. Set it up programmatically like this.
(Sorry for the JavaScript/NativeScript code, hope everyone can understand it)