I have a confusion about ImageButton
. I can make an ImageView
clickable and use as button, so why do we explicitly need an ImageButton
? When designing Android app, I found ImageView
is much more useful than ImageButton
, perhaps I missed some of the features of ImageButton
. So I want to know what are the advantages of using ImageButton
? Thanks.
ImageButton has the same property as ImageView . Only one feature is extra, which is, images set through ImageButton are clickable, and actions can be attached with them upon clicking. Just like a button, the setOnClickListener() can be used to set an event listener for click event on this.
So fundamentally, a Button can have text and is clickable, whereas an ImageButton is a bit more flexible in how you set the image. It has methods from its ImageView base class like setImageURI which a Button does not.
Displays image resources, for example Bitmap or Drawable resources. ImageView is also commonly used to apply tints to an image and handle image scaling.
This question was answered quite thoroughly here: Difference between a clickable ImageView and ImageButton
To sum it up: There's no differences, except default style. ImageButton has a non-null background by default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With