Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use ImageButton rather than ImageView?

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.

like image 244
orchidrudra Avatar asked May 23 '12 10:05

orchidrudra


People also ask

What is the difference between ImageView and ImageButton?

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.

What is the difference between Button and ImageButton in android?

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.

What is ImageView?

Displays image resources, for example Bitmap or Drawable resources. ImageView is also commonly used to apply tints to an image and handle image scaling.


1 Answers

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.

like image 179
Chikilah Avatar answered Oct 08 '22 09:10

Chikilah