【发布时间】:2016-12-29 10:25:59
【问题描述】:
Titanium appcelerator 水平滚动时,ui 垂直滚动。无论如何在水平滚动时锁定垂直滚动?
【问题讨论】:
标签: titanium appcelerator horizontal-scrolling vertical-scrolling
Titanium appcelerator 水平滚动时,ui 垂直滚动。无论如何在水平滚动时锁定垂直滚动?
【问题讨论】:
标签: titanium appcelerator horizontal-scrolling vertical-scrolling
水平滚动:
<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 属性。
【讨论】: