Question

Let's say I have an image called hello.png with dimensions 200x100. I create a button using that hello.png like this:

var button = Titanium.UI.createButton({
bottom : 50,
backgroundImage : "images/hello.png",
width:100,
height:"auto";
});
window.add(button);

What would be the appearance of the height of the button on the device? Would it be 200 pixels or would it be much less than 200 (maybe say 50)?

Based on what I've found on google, the button should be 200 pixels. But when I compile the app, the button height is greatly shrunken :/

Was it helpful?

Solution

If you avoid the height=auto, it will work.It will take the parent height in some case the auto height value wont be equal to the parent window height. In the below code sample it will work as the button width will be fixed to 100 but the height will be changing accordance with the window size.

var window = Titanium.UI.createWindow();
var button = Titanium.UI.createButton({
    bottom : 50,
    backgroundImage : "assets/images/boston_college.png",
    width:100
});
window.add(button);
window.open();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top