2012-10-09 25 views
2

我正在使用葉柵3.9,並且很難製作容器滾動。這是我的視覺代碼。葉柵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中使用pointer.scrollable設置爲true來包裝「want_scroll」會起到一定的作用。但這樣做沒有區別。

<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> 

如何添加滾動到一個簡單的容器?

請注意,通過滾動,我只想容器是可滾動的,我的問題不是關於在右側顯示滾動條。

回答

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 
      } 
     } 
}