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,因此会遇到大量问题,如语法错误或其他编码错误。 –