I have 45 buttons which i have created by loop in java code. Now i need to set and change the background image depending on the user interaction and also need resize the image also depending on the button. It will be help-full for me if i can do everything for an image button in java.
How i can resize the background image of a button in java code.
If you want to resize an image on basis of the dimension of a Button, use
getHeight()andgetWidth()methods to get the size of the button and use following function to resize image for Button:Resizing a Bitmap:
Now you can use
setBackgroundDrawable()orsetBackgroundResource()methods on a Button object to change its Background Image and you can resize a Button viasetHeight()andsetWidth()methods.Reference