2012-10-09 129 views
1

所以我有这样的代码:钛:添加的东西滚动型

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', 
}); 
var answerButton = Ti.UI.createButton({ 
    top: '1%', 
    left: '1%', 
    title: answer.answer, 
    value: answer.order, 
    width:'98%', 
    font : {fontSize:'12sp'}, 
}); 
row.add(answerButton); 
return row; 
} 

的问题是,在混账东西覆盖所有的按键为一体...也就是说,它不是“下推”行。从钛教程这里:

http://docs.appcelerator.com/titanium/2.1/index.html#!/api/Titanium.UI.ScrollView

我还以为这会工作,但事实并非如此。我知道我可以用数字做一些神奇的事情,并将每一排发送给它应该有的位置,但我认为也许钛会很聪明地做到这一点?我错过了什么吗?

回答

1

哦,耶稣。

钛是在这种情况下鲁钝 - 问题是我有

高度:在每一行定义“汽车” - 那就是:

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, 
    }); 
... 

,一切都很好。

+4

您可以在滚动视图上设置'layout:'vertical''属性,因此当您向其添加子项时,它们可以正确无间隔地重叠 – Ronnie