Android Question Center an image within a button

Discussion in 'Android Questions' started by Rusty, May 1, 2015.

  1. Rusty

    Rusty Well-Known Member Licensed 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
     
  2. Peter Simpson

    Peter Simpson Expert Licensed User

  3. Beja

    Beja Expert Licensed 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.
     

    Attached Files:

  4. Cableguy

    Cableguy Expert Licensed 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
     
    Peter Simpson likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice