Search code examples
pythonkivy

Kivy ScrollView - Not Scrolling


Looks like a common problem people have with Kivy. I've already checked other questions for the same problem here on SO but no luck.

I have a container BoxLayout:

class Cnt(BoxLayout):
    pass

In the .kv file I've got something like this:

<Cnt>:
    orientation: 'vertical'
    ScrollView:
        size_hint: (1, .9)
        StackLayout:
            padding: 5
            size_hint_y: None
            id: content_layout
            minimum_height: self.height
            ARow:
            ARow:
            ARow:
            ARow:
            ARow:
            ARow:
            ARow:
            ARow:
            ARow:
            ARow:
            ARow:
            ARow:
            ARow:
            ARow:
            ARow:
    BoxLayout:
        size_hint: (1, .1)
        Label:
            text: 'A'

ARow is a BoxLayout with a CheckBox and a Label. It has:

size_hint: (1, None)
height: 40

As far as I understand these are the only two important things that could do something to the scrolling.

minimum_height: self.height is the same as if I would bind the minimum_height and height of the StackLayout in Python code if I understood it right.


Solution

  • Change

    minimum_height: self.height
    

    to

    height: self.minimum_height
    

    The minimum_height is what's calculated as needed for all the children. You want the actual height to be equal to the minimum height, even if it's larger than the parent's height (for scrolling, this is exactly what you want).