我正在使用Kivy开发一个Android应用程序,我想知道如何在Scrollview中添加MDCard?目前我正在使用k



每当我尝试这个代码时,我都会收到错误,而且如果我只保留MDCard,那么它也会出现,但不会出现在Scrollview中。这是我的代码:

ScrollView:
do_scroll_x: False
do_scroll_y: True
Label:
size_hint_y: None
height: self.texture_size[1]
text_size: self.width
padding: 10, 10
text:
'My textn' * 100
MDCard:
Label:"Hello"

从ScrollView文档:

ScrollView只接受一个子

这可能是您出错的原因。在你的kv文件中试试这样的东西:

ScrollView:
do_scroll_x: False
do_scroll_y: True
BoxLayout:
orientation: 'vertical'
size_hint_y: None
height: self.minimum_height
Label:
canvas.before:
Color:
rgba: 1,0,0,1
Rectangle:
pos: self.pos
size: self.size
size_hint_y: None
height: self.texture_size[1]
padding: 10, 10
text:
'My textn' * 100
MDCard:
Label:
text: "Hello"
size_hint: 1, None
height: self.texture_size[1]

最新更新