我创建了简单的表格 View 应用程序,在 tableViewRow 中显示一些数据。目前,我只使用固定测量,这是我的代码:
function addTableView(){
var tableData = [];
for (var i = 0; i<10; i++){
var row = Ti.UI.createTableViewRow({
className:'forumEvent', // used to improve table performance
rowIndex:i, // custom property, useful for determining the row during events
selectionStyle:0,
});
var checkBox = Ti.UI.createSwitch({
style:Ti.UI.Android.SWITCH_STYLE_CHECKBOX,
value:false,
left:5
});
var lblField = Ti.UI.createLabel({
realValue: 'Value',
text:'Field : Value',
font:{fontFamily:'Arial', fontSize:DefaultFontSize, fontWeight:'normal'},
color:'#222',
top:5,
left:80
});
var lblField2 = Ti.UI.createLabel({
realValue: 'Value',
text:'Field : Value',
font:{fontFamily:'Arial', fontSize:DefaultFontSize, fontWeight:'normal'},
color:'#222',
top:35,
left:80
});
var lblField3 = Ti.UI.createLabel({
realValue: 'Value',
text:'Field : Value',
font:{fontFamily:'Arial', fontSize:DefaultFontSize, fontWeight:'normal'},
color:'#222',
top:65,
left:80
});
row.add(checkBox);
row.add(lblField);
row.add(lblField2);
row.add(lblField3);
checkBox.addEventListener('click',function(e){
alert(checkBox.toImage().width);
});
tableData.push(row);
}
var tempTable = Titanium.UI.createTableView({
data:tableData,
editable: Titanium.Platform.osname === 'iphone' ? true : false,
name:'Picking table'
});
return tempTable;
}
在更大的屏幕上,可以完美显示如下:
但是如果我将模拟器屏幕更改为 QVGA,它就无法像以前一样显示,如下所示:
有谁知道如何创建相对布局,以便在小屏幕和大屏幕上都能完美显示?之前谢谢..
最佳答案
var _p = function(densityPixels) {
return densityPixels * Ti.Platform.displayCaps.dpi / 160;
}
var logoView = Ti.UI.createView({
backgroundImage : '/images/logo.png',
top : _p(100),
width : _p(200),
height : _p(360)
});
关于javascript - 如何为不同的android屏幕尺寸创建相对布局钛tableViewRow?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13341942/