Kivy BoxLayout size_hint not working?

2.5k Views Asked by At

i observed that size_hint_x doesn't work in BoxLayout, e.g.

BoxLayout:
    Button:
        Size_hint_x: #any value above zero has same effect, it streches to full x axis width.

or

BoxLayout:
    orientation: 'vertical'
    Button:
        Size_hint_y: #any value above zero has same effect, it streches to full y axis width.

same for Popup, if i put value to zero it sets to a particular height or width, but if i use screen it works correctly.

Am i missing something according to BoxLayout?

1

There are 1 best solutions below

1
On

it streches to full x axis width

It stretches to full x axis only if Button is single element inside BoxLayout: it can't resize button since there's nothing to fill space of layout with.

Add at least some empty FloatLayout to achieve effect you want:

BoxLayout:    
    FloatLayout:

    Button:
        text: 'test'
        size_hint: 0.2, 0.2