我正在使用级联3.9,并且很难进行容器滚动。这是我在视觉中的代码。
<stackLayout id="parent_container" dockLayout.halign="center"
y="60"
height="{contentHeight}"
width="{contentWidth}"
>
<gridLayout columns="2" width="{contentWidth}" id="want_scroll">
<text string="First Name" />
<text string="First name goes here" font="{@csm.fc.font.h4}" />
<text string="Last Name" />
<text string="Last name goes here" font="{@csm.fc.font.h4}" />
// more items, causing the height to be more than that of the parent
</gridLayout>
我希望“want_scroll”能够滚动,因为它的高度大于{contentHeight},即“parent_container”的高度。我认为在scrollView中包装“want_scroll”并将pointer.scrollable设置为true就可以了。但这样做没有任何区别。
<scrollView pointer.scrollable="true">
<gridLayout columns="2" width="{contentWidth}" id="want_scroll">
<text string="First Name" />
<text string="First name goes here" font="{@csm.fc.font.h4}" />
<text string="Last Name" />
<text string="Last name goes here" font="{@csm.fc.font.h4}" />
// more items, causing the height to be more than that of the parent
</gridLayout>
</scrollView>
如何将滚动添加到简单容器?
请注意,通过滚动,我只希望容器可滚动,而我的问题不是关于在右侧显示滚动条。
答案 0 :(得分:1)
您还需要设置ScrollView的大小,以便它知道何时滚动。这是一个例子:
import bb.cascades 1.0
Page {
content: Container {
layout: StackLayout { }
ScrollView {
content: Container {
layout: StackLayout { }
Label {
text: "Start"
}
//snip... A bunch more labels would go here...
Label {
text: "End"
}
}
minWidth: 500
minHeight: 1280
}
}
}