Questions tagged [imagebutton]

An image button is a button that displays an image, regardless of platform

An image button is a button that displays an image, regardless of platform

1801 questions
10
votes
2 answers

How to create an Image button in MVC 4

How do you create a plain old image button in MVC 4 (Razor)? I'm looking for something like this
Swifty
  • 1,422
  • 2
  • 18
  • 38
10
votes
6 answers

ImageButton with different states images size

How can I prevent an ImageButton from having a fixed size? The drawables used in the selector have different size, and I want the ImageButton to resize itself to match the image size. I've tried adjustViewBounds without success.
gdelente
  • 776
  • 8
  • 14
9
votes
1 answer

How to extend ImageButton correctly?

I want to extend the functionality of the ImageButton class, in a new class I choose to call "DialButton". To start off, I simpy extend ImageButton, and added nothing new. In my mind, this should be identical to the normal ImageButton class. package…
fred
  • 1,812
  • 3
  • 37
  • 57
9
votes
3 answers

Array of ImageButtons, assign R.view.id from a variable

Hey there. My app is going to be using an array of 64 ImageButtons (8x8), and they're all already declared in my XML Layout with names like one1, two5, eight8, etc. Rather than declare these each individually in my Java I thought it might be smart…
Nick
  • 6,900
  • 5
  • 45
  • 66
9
votes
3 answers

Android: How to prevent image from being scaled in ImageView or ImageButton?

How can I prevent my bitmap from being scaled automatically in an ImageView or ImageButton if the view or button is stretched using "fill_parent" or using "weight"? This will be useful, for example, to create a 4-button toolbar at the top of the…
user277827
  • 207
  • 1
  • 4
  • 5
9
votes
7 answers

Android Image on Image button not displayed

I facing the problem that, I cant add new image button to my XML file.I added my icons to Drawable, but It cannot show in image button. XML shows an error ImageButton class not found. How can I solve this ? I got the following error in xml The…
user3197109
9
votes
3 answers

Creating Imagebutton programmatically

I want to create several ImageButtons programmatically. I am able to create them but the click event listener keeps receiving the same view (Button 2), whether I click on button 0 ,button1 or button 2. RelativeLayout gameBoard = (RelativeLayout)…
TranT
  • 121
  • 2
  • 2
  • 6
9
votes
4 answers

Remove image resource of ImageButton

I have a transparent ImageButton. When clicked, the ImageResource of the button is set to a drawable in my drawable-hdpi folder (basically an image is shown on top of the transparent ImageButton). I'm using the ImageButton.setImageResource()…
corecase
  • 1,278
  • 5
  • 18
  • 29
9
votes
1 answer

clipChilren set to false still clipping

I am using a translate animation to move an egg(ImageButton) outside of the carton(ImageView), but it is consistently clipping, so I looked all over stackoverflow to find a solution, but after trying to implement all the solutions, it is still…
Rogue
  • 117
  • 1
  • 7
8
votes
12 answers

ImageButton: Force square icon (height = WRAP_CONTENT, width = ?)

In my horizontal LinearLayout I have a TextEdit and an ImageButton. The ImageButton is as high as the TextEdit. I'd like that the ImageButton is exactly as wide as it's long. At the moment it looks like the width of the ImageButton is like when…
SecStone
  • 1,733
  • 4
  • 20
  • 31
8
votes
4 answers

How to add a text under the image button in Android?

I want to add text under a image button, which are also clickable, and will be redirected to the same activity as the image button. basically it's like the app list in any android phone, e.g.
Xiao Han
  • 1,004
  • 7
  • 16
  • 33
8
votes
1 answer

Setting Button's margin programmatically

I am new to android and stuck in a very basic problem.I am working on an application in which I need to swipe images on fling.On every image I have to add buttons dynamically.I am adding buttons using AddContentView() to add buttons.Everything is…
user1022105
  • 101
  • 1
  • 2
  • 5
8
votes
1 answer

How to align the image source within the ImageButton?

I have an image button that I want to take to entire width of the device. The image src I am using is not as long as the button. The default seems to be to align it to the cener of the button. Instead I would like to align it to the left. I have…
Mel
  • 6,214
  • 10
  • 54
  • 71
8
votes
1 answer

setTooltipText() and android:tooltipText are not working in Nougat

I have an ImageButton, when I did some test for my app, I found that I could not show the tooltipText in my Xiaomi Note 4 with Android N device. But it shows up perfectly fine in my Samsung S8 with Android O, any idea why this can happen and how to…
litaoshen
  • 1,762
  • 1
  • 20
  • 36
8
votes
5 answers

Android imagebutton how to change icon size

I have been working on interfaces lately and I have many problems with imagebutton sizes. I'm very bad at designing stuff and I'm having major problems with the Android Icons. Thus, I have some questions regarding those. First of all this is my…
Loic O.
  • 486
  • 2
  • 7
  • 22