Javascript 钛合金:图像->“自动”

Javascript 钛合金:图像->“自动”,javascript,image,titanium,image-size,Javascript,Image,Titanium,Image Size,假设我有一个名为hello.png的图像,尺寸为200x100。 我使用hello.png创建了一个按钮,如下所示: var button = Titanium.UI.createButton({ bottom : 50, backgroundImage : "images/hello.png", width:100, height:"auto"; }); window.add(button); 设备上按钮的高度外观如何? 它是200像素还是远小于200像素,比如说50像素 根据我在谷歌上的发

假设我有一个名为hello.png的图像,尺寸为200x100。 我使用hello.png创建了一个按钮,如下所示:

var button = Titanium.UI.createButton({
bottom : 50,
backgroundImage : "images/hello.png",
width:100,
height:"auto";
});
window.add(button);
设备上按钮的高度外观如何? 它是200像素还是远小于200像素,比如说50像素

根据我在谷歌上的发现,这个按钮应该是200像素。但是,当我编译应用程序时,按钮高度大大缩小了:/

如果你避免使用height=auto,它会起作用。在某些情况下,auto height值将不等于父窗口高度。在下面的代码示例中,按钮宽度将固定为100,但高度将根据窗口大小而变化

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();

有没有办法让它始终保持图像的原始高度?不管其他任何事情。我想用它的背景图像设置按钮。。它将显示良好的背景图像。但是如何设置按钮的宽度和高度取决于图像的宽度和高度?请告诉我