Titanium 钛:向滚动视图添加内容

Titanium 钛:向滚动视图添加内容,titanium,Titanium,所以我有这个代码: var answerView = Ti.UI.createScrollView({ //var added top: Ti.Platform.displayCaps.platformHeight*0.55, left:Ti.Platform.displayCaps.platformWidth*0.1, width: Ti.Platform.displayCaps.platformWidth*0.8, backgroundImage: '/images/labe

所以我有这个代码:

var answerView = Ti.UI.createScrollView({ //var added
    top: Ti.Platform.displayCaps.platformHeight*0.55,
    left:Ti.Platform.displayCaps.platformWidth*0.1,
width: Ti.Platform.displayCaps.platformWidth*0.8,
backgroundImage: '/images/labelBackground.png',
borderRadius: 8,
height: Ti.Platform.displayCaps.platformHeight*0.5,
contentHeight:'auto',
    showHorizontalScrollIndicator:true,
    scrollType:'vertical',
});
for (var j = 0; j < question.answers.length; j++){
    var row = createRow(question.answers[j]);
answerView.add(row);
}
问题是,该死的东西把所有的按钮都叠加在一起。。。也就是说,它不是“向下推”行。从这里的钛教程:

我本以为这会奏效,但事实并非如此。我知道我可以用数字做一些魔术,并把每一行的位置都发送到它应该有的位置,但我想也许钛会足够聪明来做到这一点?我错过什么了吗?

哦,天哪

钛在这种情况下是愚蠢的-问题是我有

高度:每行定义中的“自动”-即:

function createRow(answer) {
    var row = Ti.UI.createView({
        width:'100%', 
        height: 'auto',
    });
...
有趣的是,这使得每一行都非常大,可能和分配给这一行的整个空间一样大。我不知道,我从没试过翻阅它。因此,只要将行的高度值更改为合理的值-我总是以显示高度为基准

现在我有

function createRow(answer) {
    var row = Ti.UI.createView({
        width:'100%', 
        height: Ti.Platform.displayCaps.platformHeight*0.1,
    });
...

一切都很好。

您只需在滚动视图上设置
布局:'vertical'
属性,这样当您向其中添加子项时,它们就可以正确间隔,没有重叠
function createRow(answer) {
    var row = Ti.UI.createView({
        width:'100%', 
        height: Ti.Platform.displayCaps.platformHeight*0.1,
    });
...