我想这样将我的按钮4个按钮彼此相邻放置。https://i.stack.imgur.com/fGIFP.png但是我有这样的按钮https://i.stack.imgur.com/yts0z.png如何更改它。这是我的代码。您好,我现在添加了更多代码,如果您想将其与其他框组合在一起该怎么办。现在我有2个保险箱。我要提问,他们每个人都会有4个选项
ScrollView:
GridLayout:
rows: 3
id :topic_grid
size_hint_y: None
spacing: 40,70
height: self.minimum_height
row_default_height: "3500dp"
row_force_default: True
BoxLayout:
orientation: "vertical"
# question 1
Label:
color: 1,0,0,1
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "Which team won the most titles in the SuperLig"
font_size: 30
Button:
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "Galatasary"
size: 30,30
border: (2, 2, 2, 2)
Button:
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "Fenerbahce"
size: 30,30
Button:
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "Trabzonspor"
size: 30,30
Button:
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "Besiktas"
size: 30,30
Label:
color: 1,0,0,1
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "Which team won the 1994 football world cup"
font_size: 30
Button:
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "Republic of Ireland"
size: 30,30
on_release:
self.background_color = 1, 0, 0, 1
Button:
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "Brazil"
size: 30,30
on_release:
self.background_color = 250,255,0,0.3
Button:
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "Germany"
size: 30,30
on_release:
self.background_color = 1, 0, 0, 1
Button:
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "USA"
size: 30,30
on_release:
self.background_color = 1, 0, 0, 1
您可以使用许多BoxLayout
。他们每个人都可以有任意数量的子代(Button
或其他BoxLayout
)。
ScrollView:
GridLayout:
rows: 3
id :topic_grid
size_hint_y: None
spacing: 40,70
height: self.minimum_height
row_default_height: "3500dp"
row_force_default: True
BoxLayout:
orientation: "vertical"
# question 1
# Label:
# color: 1,0,0,1
# pos_hint:{"top": 1,"left": 1}
# size_hint:1,1
# text: "Which team won the most titles in the SuperLig"
# font_size: 30
BoxLayout:
Button:
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "Galatasary"
size: 30,30
border: (2, 2, 2, 2)
Button:
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "Fenerbahce"
size: 30,30
BoxLayout:
Button:
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "Trabzonspor"
size: 30,30
Button:
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "Besiktas"
size: 30,30