I'm trying to learn Kivy and am trying to create margins between inner and outer layouts. For the parent layout, the size_hint and pos_hint does what it should, but for the child layout, the margin functionality works only vertically, resulting in the following:
What am I doing wrong?
Code:
BoxLayout:
size_hint: [.9, .9]
pos_hint: { 'top' : .95, 'right': .95}
canvas:
Color:
rgb: [.8, .8, .8]
Rectangle:
pos: self.pos
size: self.size
BoxLayout:
size_hint: [.9, .9]
pos_hint: { 'top' : .95, 'right': .95}
canvas:
Color:
rgb: [.6, .6, .6]
Rectangle:
pos: self.pos
size: self.size
I also think you can use the floating layout.
But I guess that you want to do a design using padding
and spacing
here.
The code below will give padding and spacing like the image.
BoxLayout:
size_hint: [.9, .9]
pos_hint: { 'top' : .95, 'right': .95}
# Add padding and spacing
orientation: 'vertical'
padding: 50
spacing: 100
canvas:
Color:
rgb: [.8, .8, .8]
Rectangle:
pos: self.pos
size: self.size
# Add New BoxLayout
BoxLayout:
canvas:
Color:
rgb: [.6, .6, .6]
Rectangle:
pos: self.pos
size: self.size
BoxLayout:
canvas:
Color:
rgb: [.6, .6, .6]
Rectangle:
pos: self.pos
size: self.size
Image of padding and spacing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With