Kivy - 底部和右侧位置小部件和边距

问题描述 投票:0回答:1

我试图将小部件放在底部和右侧位置,边距为 16dp,但是我尝试了多种方法,使用多种布局,但它不起作用。有人可以帮助我吗?

ex35.py

from kivy.app import App
from kivy.core.window import Window
Window.clearcolor = (1, 1, 1, 1)

class Ex35(App):
    pass

Ex35().run()

ex35.kv

FloatLayout:
    BoxLayout:
        orientation:'vertical'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'

    Widget:
        id: ellipse
        size_hint: (None, None)
        size: (dp(56), dp(56))
        canvas:
            Color:
                rgba: 0, 1, 0, 1
            Ellipse:
                size: self.size

python kivy kivy-language
1个回答
0
投票

我用下面的代码得到了它:

FloatLayout:
    BoxLayout:
        orientation:'vertical'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'

    Widget:
        id: ellipse
        size_hint: (None, None)
        size: (dp(56), dp(56))
        pos_hint:{'right': 1}
        canvas.before:
            Color:
                rgba: 0, 1, 0, 1
            Ellipse:
                size: self.size
                pos: [dp(self.pos[0]) - dp(16), dp(self.pos[1]) + dp(16)]

© www.soinside.com 2019 - 2024. All rights reserved.