<InfoPage>:
anim_type: 'slide_above_simple'
id: main_win
box_button_anchor: box_button_anchor.__self__
three_labels_box: three_labels_box.__self__
box_phonetic: box_phonetic.__self__
BoxLayout:
BoxLayout:
id: main_box
orientation: 'vertical'
spacing: 20
canvas.before:
Color:
rgba: (1,1,1,1)
Rectangle:
pos: self.pos
size: self.size
source: 'image/back.jpg'
BoxLayout:
orientation: 'vertical'
id: word_phonetic_box
Label:
id: word_to_study
font_size: '50sp'
color: 1, 0, 0, 1
BoxLayout:
orientation: "horizontal"
id: box_phonetic
spacing: 8
AnchorLayout:
ImageButton:
id: phonetic_image
source: "image/play_button.png"
size_hint: None, None
size: 50, 22
anchor_x: "right"
anchor_y: "top"
效果如图所示,小喇叭跑哪儿去了
将最后代码稍作修改,就达到想要的效果了。
AnchorLayout:
anchor_x: "right"
anchor_y: "top"
ImageButton:
id: phonetic_image
source: "image/play_button.png"
size_hint: None, None
size: 50, 22
那如何在第一种代码的基础上达到一样的效果呢?
通过调查官方的文档发现
这俩值默认是center,也就是说 第一种方法根本就不起作用,AnchorLayout接收不到ImageB utton 的anchor_x: 和anchor_y:的值。
那如何才能接收到该children ---ImageButton的anchor_x: 和anchor_y:的值, 以达到我们可以
在一个AnchorLayout里布置 两个children呢?
我没找到一个办法, 用别的Layout吧,这玩意我已经report 在Github的 Issue里了。