我正在Kivy中创建可滚动的框布局,但是即使将框布局放在ScrollView中也无法滚动
from kivy.app import App
from kivy.lang import Builder
from kivy.base import runTouchApp
from kivy.uix.button import Button
from kivy.uix.scrollview import ScrollView
kv = '''
ScrollView:
## size=(root.width, root.height)
do_scroll_y: True
BoxLayout:
orientation: 'vertical'
Label:
size_hint: (1,None)
size: (100,100)
text: 'my text'
Label:
size_hint: (1,None)
size: (100,100)
text: 'my text'
Label:
size_hint: (1,None)
size: (100,100)
text: 'my text'
Label:
size_hint: (1,None)
size: (100,100)
text: 'my text'
Label:
size_hint: (1,None)
size: (100,100)
text: 'my text'
Label:
size_hint: (1,None)
size: (100,100)
text: 'my text'
Label:
size_hint: (1,None)
size: (100,100)
text: 'my text'
Label:
size_hint: (1,None)
size: (100,100)
text: 'my text'
Label:
size_hint: (1,None)
size: (100,100)
text: 'my text'
Label:
size_hint: (1,None)
size: (100,100)
text: 'my text'
Label:
size_hint: (1,None)
size: (100,100)
text: 'my text'
Label:
size_hint: (1,None)
size: (100,100)
text: 'my text'
class theApp(App):
def build(self):
return runTouchApp(Builder.load_string(kv))
if name == 'main':
theApp().run()
预期结果是可滚动的框布局。但实际结果是不可滚动的。在搜索了ScrollView之后,我发现我只需要在其中放入布局即可,它很容易工作,但在这种情况下不行。让我知道我的错误是什么。
答案 0 :(得分:0)
尝试为BoxLayout小部件设置高度限制,并将BoxLayout小部件的size_hint_y属性设置为“无”。
BoxLayout:
size_hint_y: None
height: self.minimum_height
...