0
鈦Appcelerator在水平滾動時,UI是垂直滾動。無論如何,鎖定水平滾動時的垂直滾動?Titanium Android臥式和立式滾動
鈦Appcelerator在水平滾動時,UI是垂直滾動。無論如何,鎖定水平滾動時的垂直滾動?Titanium Android臥式和立式滾動
對於水平滾動:
<Alloy>
<Window backgroundColor="white">
<ScrollView backgroundColor="gray" layout="horizontal" width="Ti.UI.FILL" height="Ti.UI.SIZE" scrollType="horizontal">
<View left="10" width="100" height="100" backgroundColor="red" />
<View left="10" width="100" height="100" backgroundColor="red" />
<View left="10" width="100" height="100" backgroundColor="red" />
<View left="10" width="100" height="100" backgroundColor="red" />
<View left="10" width="100" height="100" backgroundColor="red" />
<View left="10" width="100" height="100" backgroundColor="red" />
<View left="10" width="100" height="100" backgroundColor="red" />
<View left="10" width="100" height="100" backgroundColor="red" />
<View left="10" width="100" height="100" backgroundColor="red" />
</ScrollView>
</Window>
</Alloy>
對於垂直滾動:
<Alloy>
<Window backgroundColor="white">
<ScrollView backgroundColor="gray" layout="vertical" width="Ti.UI.SIZE" height="Ti.UI.FILL" scrollType="vertical">
<View top="10" width="100" height="100" backgroundColor="red" />
<View top="10" width="100" height="100" backgroundColor="red" />
<View top="10" width="100" height="100" backgroundColor="red" />
<View top="10" width="100" height="100" backgroundColor="red" />
<View top="10" width="100" height="100" backgroundColor="red" />
<View top="10" width="100" height="100" backgroundColor="red" />
<View top="10" width="100" height="100" backgroundColor="red" />
<View top="10" width="100" height="100" backgroundColor="red" />
<View top="10" width="100" height="100" backgroundColor="red" />
</ScrollView>
</Window>
</Alloy>
鈦經典例子
var win = Ti.UI.createWindow({
backgroundColor : 'white'
});
var scrollview = Ti.UI.createScrollView({
backgroundColor : "gray",
layout : "horizontal",
width : Ti.UI.FILL,
height : Ti.UI.SIZE,
scrollType : "horizontal"
});
for (var i=0; i<=10; i++) {
scrollview.add(createView());
}
win.add(scrollview);
win.open();
function createView() {
return Ti.UI.createView({
backgroundColor : 'red',
width : 100,
height : 100,
left : 10
});
}
您在Android上限制滾動方向的關鍵點是scrollType屬性。
我不使用合金。我怎樣才能解決這個從JavaScript文件?我沒有使用合金。 –
只需將scrollType屬性設置爲「水平」或「垂直」,具體取決於您的情況,例如Prashant Saini說 –
使用經典代碼編輯了我的答案。但是,建議您在開始面對巨大的代碼之前儘快熟悉Alloy,因此會遇到大量問題,如語法錯誤或其他編碼錯誤。 –