Button with background image, sizing

You must Login before you can answer or comment on any questions.

If I create a button with a background image

Ti.UI.createButton({backgroundImage:'red.png'});
The size is wrong. I tried setting width and size to Ti.UI.SIZE, 'auto', '100%', but it's not using the actual image size. I don't want to hardcode a size because the size would be different on ios and android at different resolutions.

How can I get the button to size itself to the image?

1 Answer

Accepted Answer

I would suggest, if it's not overkill, why not create a utility function that gets the size from the image blob and then set the size of the button to it. Otherwise, the background image is always resized to the button, not otherwise

— answered 8 months ago by Richard Lustemberg
answer permalink
1 Comment
  • I guess that has to be it. It will load the image twice, unfortunately, because setting the backgroundImage is only from a String.

    — commented 8 months ago by ERIC HERRMANN

Your Answer

Think you can help? Login to answer this question!