Kivy BoxLayout set height equal to children height
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_string("""
<LayoutTest>:
orientation: 'vertical'
padding: 20
spacing: 10
BoxLayout:
orientation: 'horizontal'
padding: 0
spacing: 0
size_hint_y: None # I want the "row" height to be equal to the AsyncImage height (1/3rd screen width), see
# comment below
AsyncImage:
# I want this image to be 1/3rd screen width, hence the size_hint_x = 0.66, but I want the height of this
# image to be equal to the width (also 1/3rd screen width).
size_hint_x: 0.66
source: 'http://placehold.it/400x400'
allow_stretch: True
Widget:
canvas:
Color:
rgba: 1, 0, 0, 0.2
Rectangle:
size: self.size
pos: self.pos
BoxLayout:
orientation: 'horizontal'
padding: 0
spacing: 0
Widget:
size_hint_x: 0.1
canvas:
Color:
rgba: 1, 1, 0, 0.2
Rectangle:
size: self.size
pos: self.pos
Widget:
canvas:
Color:
rgba: 0, 1, 1, 0.2
Rectangle:
size: self.size
pos: self.pos
""")
class LayoutTest(BoxLayout):
pass
class MainApp(App):
def build(self):
return LayoutTest()
if __name__ == '__main__':
MainApp().run()