【问题标题】:Cascades 3.9 - making a container scrollCascades 3.9 - 制作容器滚动
【发布时间】:2012-09-30 06:36:48
【问题描述】:

我正在使用 cascades 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”的高度。我认为将“want_scroll”包装在scrollView中,将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>

如何将滚动添加到一个简单的容器中?

请注意,通过滚动,我只希望容器可以滚动,我的问题不是关于在右侧显示滚动条。

【问题讨论】:

    标签: xml scroll scrollview cascade


    【解决方案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
               }
          }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-26
      • 1970-01-01
      • 2015-08-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多