Difference between an image button, ImageButton, and an interactive ImageView?

Is there any difference between Button with image, ImageButton and clickable ImageView ?

+61
android button imagebutton
Feb 23 '12 at 20:08
source share
5 answers

This probably only covers some of the differences, it would be useful to look at the Android file tree to see exactly what is going on.

ImageButtons have push states where there is no clickable image. You also cannot call setText for an ImageButton, you can use a regular button.

They all come from the view, but finding the next extension chain may help a little.

 java.lang.Objectandroid.view.Viewandroid.widget.ImageViewandroid.widget.ImageButton 

against

 java.lang.Objectandroid.view.Viewandroid.widget.TextViewandroid.widget.Button 
+82
Feb 23 2018-12-21T00:
source share

Differences may be slight. The most direct way to understand this is to start by reviewing the documents. If you look at the docs for Button , you will see that Button comes from TextView . ImageButton , on the other hand, is derived from ImageView . Basically, Button can have text and is ImageButton , while ImageButton is more flexible in how you set the image. It has methods from its base ImageView class, such as setImageURI , which a Button does not have. One of the differences between the two and just the regular ImageView is that you can have button states, which are explained in both the Button and ImageButton .

+11
Feb 23 2018-12-12T00:
source share
 ImageView = Display Images (android:src) 

ImageButton = Diaplay Images like imageView and get click act like a button (android:src) and cannot set text for it.

 Button = set text and (android:background) 
+9
Feb 25 2018-12-12T00:
source share

Another aspect not mentioned in previous answers is the use inside (for example) of the presentation of the list item. If you insert a Button or ImageButton, the rest of the list item will not receive touch events. But if you use ImageView, it will.

+4
Jan 25 '14 at 17:43
source share
 button instanceof ImageButton == false; imageButton instanceof Button == false; button instanceof TextView == true; imageButton instanceof ImageView == true; 
+1
Jan 07 '16 at 15:07
source share



All Articles