【问题标题】:Titanium: Image -> "auto"钛:图像->“自动”
【发布时间】:2011-12-26 09:48:00
【问题描述】:

假设我有一张名为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 像素。但是当我编译应用程序时,按钮高度大大缩小了:/

【问题讨论】:

    标签: javascript image titanium image-size


    【解决方案1】:

    如果你避开height=auto,它会起作用。在某些情况下,它会采用父高度,自动高度值不会等于父窗口高度。在下面的代码示例中,它将工作,因为按钮宽度将固定为 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();
    

    【讨论】:

    • 有没有办法让它总是取图像的原始高度?不管其他什么。
    • 我想用它的背景图像设置按钮。它会很好地显示背景图像。但是我如何设置按钮的宽度和高度取决于图像的宽度和高度?请建议我
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多