好吧,@Manuel_Rodrigues 我不明白你的问题!如果您在 Titanium 中遇到此问题,以下建议可能会对您有所帮助。首先,你说的LabelViews是Label还是View的UI组件?而且,根据您的描述,我想知道您是否想要执行类似 CHAT IN TEXT 的操作,以便在最后一个人的聊天内容下跟踪聊天内容。如果这是你想要的,那么:
1.使文本自动适应标签
var label = Ti.UI.createLabel({
font:{
fontSize: '18' //text font size
},
top: 10, //the distance between the labels
width: 'auto', //automatic define width by the text
height: 'auto', //automatic define height by the text
textAlign: 'center', //text display in the center of the label in horizontal direction
verticalAlign: Ti.UI.TEXT_ALIGNMENT_CENTER //text display in the center of the label in vertical direction
});
请注意:
如果将width和height都设置为auto,当文字过长手机屏幕无法显示时所有内容,标签不会换行来显示其余文本。所以,更好的办法是给宽度设置一个指定值或者等于手机屏幕的宽度。
2.下一个标签自动显示在上一个标签下
如果您选择 View 作为这些标签的父级,则应将 layout 属性设置为 vertical。好吧,如果只有您定义的 window,请执行相同的操作。
var view = Ti.UI.createView({
width: '100%',
height: 'auto',
layout: 'vertical'
});
view.add(label1);
view.add(label2);
...
或者对于窗口:
var win = Ti.UI.createWindow({
width: '100%',
height: '100%',
layout: 'vertical'
});
win.add(label1);
win.add(label2);
...
希望对你有帮助!