我是鈦的新手,並嘗試瞭解視圖如何工作,我面臨的問題。鈦視圖高度和內容
我已創建一個包含一個圖像和2個標籤的視圖。
var row = Titanium.UI.createTableViewRow({height:'auto'});
var item_view = Titanium.UI.createView({
height:'100%',
layout:'vertical',
top:5,
right:5,
bottom:5,
left:5
});
var item_image = Titanium.UI.createImageView({
url:imageUrl, // the image for the image view
top:0,
left:0,
height:97,
width:65
});
item_view.add(item_image);
var productName_lbl = Titanium.UI.createLabel({
text:productName,
left:70,
width:'auto',
top:-97,
bottom:2,
height:'auto',
textAlign:'left',
color:'#444444',
font:{fontFamily:'Trebuchet MS',fontSize:12,fontWeight:'bold'}
});
item_view.add(productName_lbl);
var comName_lbl = Titanium.UI.createLabel({
text:comName,
left:70,
width:'auto',
top:7,
bottom:2,
height:'auto',
textAlign:'left',
color:'#444444',
font:{fontFamily:'Trebuchet MS',fontSize:12,fontWeight:'bold'}
});
item_view.add(comName_lbl);
問題是圖像的高度爲97px,但左側的標籤都有較小的高度。
結果是圖像現在顯示100%,但只顯示左側標籤的高度。 請記住,標籤也許真的很長的文本,所以我有標籤寬度,高度自動
我試圖將行高從自動更改爲100%,但仍然無法正常工作。
任何幫助表示讚賞
做佈局時:「垂直」時,請務必添加高度:「10dp」或高度:Ti.UI.SIZE,通常它修復了計算視圖高度時的錯誤。 – keithics
@keithics我不認爲你的方法如上所述。我設置了我的視圖高度:10dp,佈局:垂直。關聯的視圖全部設置爲10dp。我誤解了你的意思嗎? –