Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageView vs ImageButton vs Button

In my layout, I have some images that are to be the button background (no text). I am confused to how I should go about it. There are a few options to achieve this -

  1. Button
  2. ImageButton
  3. ImageView

Personally, I prefer the ImageView so I can scale the images appropriately and then set onClickListener.

Am I missing something or are there performance issues with my approach? Pros and Cons of each will help a lot.

Thanks & Regards

R

like image 730
Rahul Thakur Avatar asked Sep 15 '14 03:09

Rahul Thakur


People also ask

What is the difference between ImageView and ImageButton?

There's no differences, except default style.

What is difference between Button and image button?

ImageButtons has push states, where as a clickable image does not. You also can't call setText for ImageButton, you can with a regular button. They all derive from view, but looking at the following extends chain may help a little.

Is ImageView clickable?

You can make a view clickable, as a button, by adding the android:onClick attribute in the XML layout. For example, you can make an image act like a button by adding android:onClick to the ImageView. In this task you create a prototype of an app for ordering desserts from a café.

What is ImageView?

ImageView class is used to display any kind of image resource in the android application either it can be android. graphics. Bitmap or android. graphics. drawable.


1 Answers

There are a lot of in-depth answers to the question but the 3 main differences in my opinion are

  1. Button - 3d rendering of a button that has text.
  2. ImageButton - 3d rendeirng of a button but instead of text you are using an image.
  3. ImageView - a flat image.

ImageButton and Button have the pressed,selected, focused, unselected states that can convey to the user the different states of the button.

I don't believe there are any performance benefits of using one vs, the other but there are definitely UI and UX reasons to use each one. ImageView I would assume would be good to display just the image. Users won't really know that they can click on the Image.. but with the button counterparts users are trained that they should click on them.

like image 154
reidisaki Avatar answered Oct 19 '22 11:10

reidisaki