【发布时间】:2015-04-12 21:20:21
【问题描述】:
这是我想要完成的,应该很简单:标签中的标题文本,下面列出了一些垂直按钮并嵌套在右侧
一审:
#:kivy 1.9.0
<SubjectButton@Button>:
size_hint: None, None
size: 40, 160
BoxLayout:
orientation: "vertical"
Label:
text: "Choose Subject:"
font_size: "16sp"
bold: True
halign: "left"
BoxLayout:
orientation: "vertical"
padding_horizontal: 20
SubjectButton:
text: "Subject 1"
SubjectButton:
text: "Subject 2"
SubjectButton:
text: "Subject 3"
SubjectButton:
text: "Subject 4"
结果:
二审:
#:kivy 1.9.0
#: set sb_width 120
#: set sb_height 40
#: set sb_margin_left 20
<SubjectButton@Button>:
size_hint: None, None
height: sb_height
width: sb_width
RelativeLayout:
Label:
text: "Choose Subject:"
font_size: "16sp"
bold: True
halign: "left"
pos: 0, root.height - 5
SubjectButton:
text: "Subject 1"
pos: sb_margin_left, root.height - sb_height
SubjectButton:
text: "Subject 2"
pos: sb_margin_left, root.height - 2 * sb_height
SubjectButton:
text: "Subject 3"
pos: sb_margin_left, root.height - 3 * sb_height
SubjectButton:
text: "Subject 4"
pos: sb_margin_left, root.height - 4 * sb_height
结果:
标签不见了!
首先让我说布局从左上角开始而显式定位在左下角的想法是愚蠢的(来自 PySide)。这应该如何工作?。
更不用说AnchorLayout 实际上不是布局而是对齐工具。只影响一个孩子。
我在这里错过了什么?
【问题讨论】: