2012-10-09 57 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