DON'T USE A TRANSAPENT OR NULL LAYOUT because then the button (or the generic view) will no more highlight at click!!!
I had the same problem and finally I found the correct attribute from Android API to solve the problem. It can apply to any view.
Use this in the button specifications:
android:background="?android:selectableItemBackground"
You can also use a transparent color:
android:background="@android:color/transparent"
Use "@null" . It worked for me.
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/bkash"
android:id="@+id/bid1"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@null" />
Try using null for the background ...
android:background="@null"
in run time, you can use following code
btn.setBackgroundDrawable(null);
This is programatically set background color as transparent
ImageButton btn=(ImageButton)findViewById(R.id.ImageButton01);
btn.setBackgroundColor(Color.TRANSPARENT);