如何在kivy中将Scroll VIew应用于Box Layout

时间:2015-12-28 10:55:39

标签: android python scroll kivy

我有很多Button,我想将scrollview应用到Box Layout,如下所示

<My Class>:
  ScrollView:
    BoxLayout:
      Button:
        text:"buttone1"
       Button:
        text:"buttone1"
       Button:
        text:"buttone1"
       Button:
        text:"buttone1"
       Button:
        text:"buttone1"
       Button:
        text:"buttone1"
       GridLayout:
         rows:4
         cols:4
         Button:
           text:"buttone1"
         Button:
           text:"buttone1"
         Button:
           text:"buttone1"
         Button:
           text:"buttone1"
         Button:
           text:"buttone1"

如何将Scrollview应用于上面的内容

2 个答案:

答案 0 :(得分:1)

将所有按钮和textview放在SINGLE布局中,并将该布局放在ScrollView中。它应该工作

答案 1 :(得分:1)

这是我找到的最简单的解决方案:

ScrollView:
  GridLayout:
        id: glayout
        cols: 1
        size_hint: (1, None)
        height: self.minimum_height
        Button:
          text:"button1"
        Button:
          text:"button2"
        Button:
          text:"button3"
    
  #Put content that you need in gridlayout