The functions of the imagebutton component are the same as those of the button component.
The difference is that the imagebutton component displays images, while the button component displays text.
Therefore, the imagebutton component allows us to deliver quality experiences to users in a vivid and interesting way.
However, when using imagebutton, you must put the image you want to add in the Res/drawable folder. The image format can be PNG, JPG, or GIF. You also need to set an ID when using imagebutton. The Android: src = "" property is used to display the image. The following example:
<Imagebutton Android: Id = "@ + ID/imgbtn"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: src = "@ drawable/Name of the image file you want to set"
/>
The other usage aspects are the same as button. You can set a listenner to implement the functions you want.
The imageview component is only used to display images. It cannot be used to set the execution program after being pressed like a button.
However, the setimageresource () method can be used when the program is running.
Differences between button imagebutton and imageview