2011-12-26 44 views
0

假設我有一張尺寸爲200x100的圖片hello.png。 我創建使用hello.png這樣的按鈕:鈦:Image - >「auto」

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

會是什麼設備上的按鈕的高度的外觀? 它會是200像素還是會比200(也許是50)少得多?

根據我在谷歌上找到的,按鈕應該是200像素。但是,當我編譯應用程序時,按鈕高度大大縮小:/

回答

0

如果您避免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(); 
+1

有沒有什麼辦法讓它始終保持圖像的原始高度?不管別的什麼。 – 2011-12-26 11:14:19

+0

我想設置其背景圖像的按鈕..它會顯示罰款與背景圖像。但我怎樣才能設置該按鈕的寬度和高度取決於圖像的寬度和高度? plz suggeest me – Hitarth 2012-03-28 12:23:45