2011-06-23 107 views
1

我想問鈦的android開發中的圖像視圖,因爲我沒有得到正確的方式來創建我的應用程序的圖像視圖。我已經採取了一個窗口,並在那我添加了一個黑色的背景顏色的視圖,並在此我想添加一個圖像,,在一個設置的位置,但即時無法使用它....鈦android應用程序開發

/////這裏是我的代碼//// //通過vishakha

var win1 = Titanium.UI.createWindow({ 
    backgroundColor:'white', height:480, width:320 
}); 
win1.open(); 
var header= Titanium.UI.createView({ 
    backgroundColor: 'black', 
    top: 0, left:0, 
    height:65, width:320 
}); 
win1.add(header); 
var backbutton= Titanium.UI.createImageView({ 
    backgroundImage:'images/back.png', 
    height: 40, 
    top:5, 
    left:5, 
    width:50 
}); 
header.add(backbutton); 

添加訪問者屏幕,但這個圖片不顯示... N 1件事我把資源文件夾中的圖片...請幫助我.. ,,希望舉一個例子..謝謝,,

+0

如果您將圖片放在'Resources/images /'中,您的文件路徑是正確的 –

回答

2

你有沒有嘗試過使用'圖像'屬性而不是'backgroundImage?'

2

而不是使用:

var backbutton= Titanium.UI.createImageView({ 
    backgroundImage:'images/back.png', 
    height: 40, 
    top:5, 
    left:5, 
    width:50 
}); 

用途:

var backbutton= Titanium.UI.createImageView({ 
    image:'/back.png', 
    height: 40, 
    top:5, 
    left:5, 
    width:50 
}); 

這是假設你的圖像文件是在資源文件夾。要創建ImageView,您需要使用圖像而不是backgroundImage。

+0

因爲剩下的信息是多餘的,所以我只會發布相關行進行更改。 – Ren