KIVY 百词斩 AnchorLayout 布局

<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里了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xinzheng新政

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值