Skip to content Skip to sidebar Skip to footer

Kivy Scroll View Does Not Scroll

I use kivys scroll view widget for the first time and I am not sure how I get this to run. I want to scroll up and done trough the different labels. How can I achieve this ? Which

Solution 1:

The ScrollView will not work if its child (the GridLayout) is smaller than the ScrollView. Typically, the GridLayout would be large enough to hold all its children (the YearLabels). Conveniently, the GridLayout can calculate that size. Here is a modified version of your kv that uses it:

ScrollView:scroll_timeout:250scroll_distance:20do_scroll_y:Truedo_scroll_x:FalseGridLayout:cols :1spacing:10padding:10size_hint_y:None# required since we are setting heightheight:self.minimum_height# let GridLayout calculate height

Also, I removed the height: 100 from the ScrollView, since it had no effect.

In order for the GridLayout to calculate minimum_height, all its children must have well defined heights. So, I added to your YearLabel rule:

<YearLabel@ButtonBehavior+Label>:
    size_hint: 1, None
    height: dp(100)

Post a Comment for "Kivy Scroll View Does Not Scroll"