Python 我的亲戚显然忽视了我的位置暗示

Python 我的亲戚显然忽视了我的位置暗示,python,kivy,android-relativelayout,Python,Kivy,Android Relativelayout,我一直在尝试为我的应用程序制作一个GUI,我学到了一些关于RelativeLayout的知识。 根据我的理解,您定义了一个变量“pos_hint”,并指定一个从0到1的值,该值表示它离该位置有多近。例如,“右”:1==100%向右 问题是,我有一个垂直的BoxLayout,包含2个RelativeLayout,其中包含小部件,其中一个也有自己的RelativeLayout。 这件事很快变得复杂起来,我正在努力找到问题的答案 我的目标是: 中上部的“SuspectGraph”,其中包含两个相互重叠

我一直在尝试为我的应用程序制作一个GUI,我学到了一些关于RelativeLayout的知识。
根据我的理解,您定义了一个变量“pos_hint”,并指定一个从0到1的值,该值表示它离该位置有多近。例如,“右”:1==100%向右

问题是,我有一个垂直的BoxLayout,包含2个RelativeLayout,其中包含小部件,其中一个也有自己的RelativeLayout。
这件事很快变得复杂起来,我正在努力找到问题的答案

我的目标是:
中上部的“SuspectGraph”,其中包含两个相互重叠的椭圆。“
右上角的“设置按钮”。
y-中间的“MoodButton”和底部框x的1/4
y-中间的“FoodButton”和底部框x的3/4

从完整的答案到关于如何修复错误的细微提示,任何帮助都将不胜感激

编辑:忘记添加代码。对不起

<MainLayout>:
    canvas:
        Color:
            rgba: 1, 1, 1, 1
        Rectangle:
            pos: 0,0
            size: self.width,self.height
    BoxLayout:
        size: self.parent.size
        orientation: "vertical"
        RelativeLayout:
            canvas:
                Color:
                    rgba: 1,0,0,1
                Rectangle:
                    size: self.width,self.height
            size: self.parent.size
            SettingButton:
                size: 50,100
                pos_hint: {'right':1,'y':1}
                Button:
                    text: "Settings"
                    size: self.size
            SuspectGraph:
                pos_hint: {'center_x':1,'center_y':1}
                RelativeLayout:
                    GraphInnerCircle:
                        pos_hint: {'center_x':1,'center_y':1}
                        size: 200,200
                        canvas:
                            Color:
                                rgba: .5,.5,.5,1
                            Ellipse:
                                size: self.size
                    GraphOuterCircle:
                        pos_hint: {'center_x':1,'center_y':1}
                        size: 300,300
                        canvas:
                            Color:
                                rgba: .3,.3,.3,1
                            Ellipse:
                                size: self.size
        RelativeLayout:
            MoodButton:
                size: 50,100
                pos_hint:{'left':.1,'center_y':.7}
                Button:
                    text: "Register Mood"
            FoodButton:
                size: 50,100
                pos_hint:{'right':.1,'center_y':.7}
                Button:
                    text: "Register Food"
:
画布:
颜色:
rgba:1,1,1,1
矩形:
位置:0,0
尺寸:自宽、自高
盒子布局:
大小:self.parent.size
方向:“垂直”
相对长度:
画布:
颜色:
rgba:1,0,0,1
矩形:
尺寸:自宽、自高
大小:self.parent.size
设置按钮:
尺寸:50100
位置提示:{'right':1,'y':1}
按钮:
文本:“设置”
大小:self.size
怀疑图:
位置提示:{'center\ux':1,'center\uy':1}
相对长度:
葡萄园:
位置提示:{'center\ux':1,'center\uy':1}
尺码:200200
画布:
颜色:
rgba:.5,5,5,1
椭圆:
大小:self.size
图形圆:
位置提示:{'center\ux':1,'center\uy':1}
尺寸:300300
画布:
颜色:
rgba:.3.3.3.1
椭圆:
大小:self.size
相对长度:
MoodButton:
尺寸:50100
位置提示:{'left':.1,'center_y':.7}
按钮:
文本:“注册语气”
食物按钮:
尺寸:50100
位置提示:{'right':.1,'center_y':.7}
按钮:
正文:“登记食品”

问题在于属性如何在嵌套小部件上工作。
以这个片段为例:

        size: self.parent.size
        orientation: "vertical"
        RelativeLayout: 
            canvas:
                Color:
                    rgba: 1,0,0,1
                Rectangle:
                    size: self.width,self.height
            size: self.parent.size
            SettingButton:
                size: 50,100
                pos_hint: {'right':1,'y':1}
                Button:
                    text: "Settings"
                    size: self.size
第12行的pos_提示适用于小部件“设置按钮”,但不适用于 按钮在里面。 我不知道为什么,但这就是它的工作原理

尝试将pos_提示直接设置到按钮不起作用,因为它将尝试从SettingButton推断其位置,而SettingButton不是布局

解决方案
将设置按钮的python端代码更改为按钮而不是小部件。
将pos_提示直接应用于设置按钮

希望这有助于任何人谷歌相同的问题