根据字符串的长度调整 TableViewRow 的高度
Adjust TableViewRow height for length of string
根据字符串的长度调整 TableViewRow 的高度。
我有表格视图,每一行都有一条消息(1-500 个字母)。
但在这段代码中,有些被省略,有些被扩展。
总的来说每行高都不稳定
有什么好的方法可以根据消息长度调整行高
var dateLabel = Ti.UI.createLabel({
top:'5%',left:'5%',
text:dateLabel,
color:"black",
font:{fontSize: Ti.App.global.myFunc.makeFont(2),fontWeight:'bold'},
});
var messageLabel = Ti.UI.createLabel({
top:'15%',left:'5%',right:'5%',
text:messageLabel,
color:"black",
font:{fontSize: Ti.App.global.myFunc.makeFont(2.8)},
});
var row = Ti.UI.createTableViewRow({backgroundColor:'white',touchEnabled:false});
row.add(messageLabel);
row.add(dateLabel);
this.sectionNews.add(row);
this.table = Ti.UI.createTableView({
zIndex:15,
backgroundColor:'white',
data: [this.sectionNews],
selectionStyle: Ti.UI.iPhone.TableViewCellSelectionStyle.NONE
});
您可以将 table rowHeight 指定为自动。
var myTable = Ti.UI.createTableView({height:400,rowHeight: 'auto', width: 312, top: 10,left:4, backgroundColor: '#FFFFFF',borderColor: '#C8C8C8',borderWidth:2, zIndex: -1});
您还可以在创建 table行作为自动高度时尝试以下代码
var row = Ti.UI.createTableViewRow({
height: 'auto'
});
版本 2.0 +
var row = Ti.UI.createTableViewRow({
height: Ti.UI.SIZE
});
根据字符串的长度调整 TableViewRow 的高度。
我有表格视图,每一行都有一条消息(1-500 个字母)。
但在这段代码中,有些被省略,有些被扩展。
总的来说每行高都不稳定
有什么好的方法可以根据消息长度调整行高
var dateLabel = Ti.UI.createLabel({
top:'5%',left:'5%',
text:dateLabel,
color:"black",
font:{fontSize: Ti.App.global.myFunc.makeFont(2),fontWeight:'bold'},
});
var messageLabel = Ti.UI.createLabel({
top:'15%',left:'5%',right:'5%',
text:messageLabel,
color:"black",
font:{fontSize: Ti.App.global.myFunc.makeFont(2.8)},
});
var row = Ti.UI.createTableViewRow({backgroundColor:'white',touchEnabled:false});
row.add(messageLabel);
row.add(dateLabel);
this.sectionNews.add(row);
this.table = Ti.UI.createTableView({
zIndex:15,
backgroundColor:'white',
data: [this.sectionNews],
selectionStyle: Ti.UI.iPhone.TableViewCellSelectionStyle.NONE
});
您可以将 table rowHeight 指定为自动。
var myTable = Ti.UI.createTableView({height:400,rowHeight: 'auto', width: 312, top: 10,left:4, backgroundColor: '#FFFFFF',borderColor: '#C8C8C8',borderWidth:2, zIndex: -1});
您还可以在创建 table行作为自动高度时尝试以下代码
var row = Ti.UI.createTableViewRow({
height: 'auto'
});
版本 2.0 +
var row = Ti.UI.createTableViewRow({
height: Ti.UI.SIZE
});