As AppCompatImageButton is an advance version of ImageButton we recommend to use AppCompatImageButton.

AppCompatImageButton is used to display a normal button with a custom image in a button. In simple words we can say, AppCompatImageButton is a button with an image that can be pressed or clicked by the users. By default it looks like a normal button with the standard button background that changes the color during different button states.

public class AppCompatImageButton extends ImageButton implements TintableBackgroundView
↳ android.view.View
  ↳ android.widget.ImageView
    ↳ android.widget.ImageButton
      ↳ androidx.appcompat.widget.AppCompatImageButton

We Recommend to use new UI components i.e. androidx components

Note: AppCompatImageButton has all the properties of a AppCompatButton so you can easily perform any event like click or any other event which you can perform on a normal button

How to create AppCompatImageButton in layout xml file

    android:src="@android:drawable/ic_menu_edit" />

As AppCompatImageButton has all properties of AppCompatButton so we can perform all operation like click and all. You can go through