Android Question Center an image within a button

Rusty

Well-Known Member
Licensed User
Longtime User
I would like to center or align an image within a button view. Currently, it appears the button view "stretches" any image to fill the entire button.
Is it possible to have an image occupy only a portion of the button.
i.e. Button is 100dip X 100dip
Image is 500 X 500, I would like the image to display at the top of the button at 50 X 50, occupying 1/4th the space within the button.
I've tried resizing the image, but when it is set as the background image, it re-stretches the resized image to fill the button.
Thanks,
Rusty
 

Beja

Expert
Licensed User
Longtime User
You can draw your (image) inside a larger image and make them one image before placing it on the button.
The attached is your image before it is placed on the button.. note the rectangle is not the button but the whole image.
 

Attachments

  • ImageOfTheDay.jpg
    ImageOfTheDay.jpg
    6.5 KB · Views: 147
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
You should give canvas and rectangle a play...
Define a canvas the same size as your button, then define a rectangle with in your canvas... Set it as your image destination.. Then set your canvas to be the buttons background
 
Upvote 0
Top