我有一个放置了滚动视图的应用程序,但是当我动态插入元素时,它们会出现,但是滚动视图不起作用。 如果有什么可以告诉我代码有什么问题, 这是我的滚动视图的代码:
我尝试过尺寸提示,do_scroll_x和其他东西。
<WorkWidget>:
orientation: "vertical"
spin_type: spinner_types
mat_in: txt_in_material
qt_in: txt_in_Qt
spin_qt: spinner_Qt
spin_ci: spinner_CI
work_layout: work_boxlayout
canvas:
Color:
rgb: [0, 0, 1, 1]
Rectangle:
pos: self.pos
size: self.size
ScrollView:
BoxLayout:
orientation: "vertical"
id: work_boxlayout
padding: dp(2)
spacing: dp(2)
GridLayout:
cols: 5
rows: 1
padding: dp(2)
spacing: dp(2)
height: self.minimum_height
size_hint_y: None
Spinner:
id: spinner_types
text: "F+M+R"
values: ("F+R", "M+R", "")
height: dp(40)
size_hint_x: 0.15
size_hint_y: None
CustomTxtIn:
id: txt_in_material
hint_text: "Mat�riel"
CustomTxtIn:
id: txt_in_Qt
hint_text: "Qt"
size_hint_x: 0.15
Spinner:
id: spinner_Qt
text: "pc(s)"
values: ("m")
height: dp(40)
size_hint_x: 0.15
size_hint_y: None
Spinner:
id: spinner_CI
text: "CI11"
values: ("CI12", "CI13", "CI20", "CI21", "CI22")
height: dp(40)
size_hint_x: 0.15
size_hint_y: None
BoxLayout:
padding: dp(2)
spacing: dp(2)
height: self.minimum_height
size_hint_y: None
CustomButton:
id: bt_add_work
text:"+"
on_press: app.root.add_work_line()
CustomButton:
id: bt_add_section
text:"Section"
on_press: app.root.add_work_section()
这是动态插入元素的方式:
def add_work_layout_child(self):
'''Adicionar uma linha de trabalho'''
grid = GridLayout(cols=5)
spin_type = Spinner(text="teste")
text_in_material = TextInput()
text_in_qt = TextInput()
spin_qt = Spinner(text="teste")
spin_ci = Spinner(text="teste")
grid.add_widget(spin_type)
grid.add_widget(text_in_material)
grid.add_widget(text_in_qt)
grid.add_widget(spin_qt)
grid.add_widget(spin_ci)
self.work_layout.add_widget(grid)
我希望插入的元素具有相同的大小并且可以滚动,但是插入元素后就无法滚动,并且元素变得如此之小以至于无法理解。
如果有人可以帮助我,我将非常感激。 最好的问候。