【发布时间】:2020-12-01 14:15:54
【问题描述】:
我一直在尝试为我的应用程序制作 GUI,并且我已经了解了一些关于 RelativeLayout 的知识。
根据我的理解,您定义了一个变量“pos_hint”,并分配一个从 0 到 1 的值,表示它与该位置的接近程度。例如。 “右”:1 == 100% 向右
问题是,我有一个垂直的 BoxLayout,包含 2 个 RelativeLayout,其中包含小部件,其中一个也有自己的 RelativeLayout。
这变得非常复杂,我正在努力寻找答案的问题。
我的目标是:
“SuspectGraph”在顶部中间,其中包含 2 个相互重叠的椭圆。”
“SettingButton”在右上角。
“MoodButton”位于 y 中间,1/4 位于底部框的 x 处
“FoodButton”位于 y 中间,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"
【问题讨论】:
标签: python kivy android-relativelayout