Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
546 views
in Technique[技术] by (71.8m points)

python - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...