0

I am debating whether to use a button OR Clickable Image view and I am not sure which way is the best?

I basically want to add buttons on my screens (a fancy nice looking button like the ones you see in games). I have the image of the button. I can either create an imageview and make it clickable or create a button and set the background to the image?

Both seems to work and both I can set the width and height to as I like. Any reason for why use one versus another in my case? Thank you

Snake
  • 14,228
  • 27
  • 117
  • 250
  • Has been answered before here http://stackoverflow.com/questions/5847136/difference-between-a-clickable-imageview-and-imagebutton – Fareya Dec 29 '14 at 21:00
  • I am not asking about ImageButton. I am asking about Button which is a totally different inheritance – Snake Dec 29 '14 at 21:01
  • It depends on the size and positioning of those clickable items. So show or explain the blueprint, if you can. – Tushar Gogna Dec 30 '14 at 04:51
  • @Psy Duck.. What do you mean? It is 3 buttons under each other in the middle of the screen. You can say the button size is 70 by 70 dp – Snake Dec 30 '14 at 05:32
  • Buttons might loose the quality of the images that you are about to use, unless they are vector images (9 patched). So I guess you should make images according to the size you want and then use them on button. If they are not 9patched/vector, use them on ImageButton or ImageView. – Tushar Gogna Dec 30 '14 at 05:45
  • Thank you.. So games use images view then most of the time? Feel free to out it as answer – Snake Dec 30 '14 at 06:46

1 Answers1

0

The main difference between them is that a button has different push states(pressed, selected, focussed etc.) that you can use, while a clickable ImageView doesn't.

max59
  • 606
  • 1
  • 7
  • 16
  • Thank you so which one do games use? buttons such as cash button, fight button.. Etc – Snake Dec 30 '14 at 05:35
  • I think most of the games use ImageButton, as it can display an image as ImageView and can have push states as well. – max59 Dec 30 '14 at 07:19
  • But imgaebutton load the image within a grey border.Also wouldn't button with background image do the same? – Snake Dec 30 '14 at 15:33
  • The border can be disabled by setting the ImageButton's background to null. And yes, a button can have a background but ImageButton has more methods to control the image. Also, with an ImageButton you can set a foreground and a background image. – max59 Dec 30 '14 at 16:58