問題描述
看起來是人們對 Kivy 的常見問題.我已經在 SO 上檢查了其他問題是否存在同樣的問題,但沒有運氣.
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.
我有一個容器BoxLayout:
class Cnt(BoxLayout):
pass
在 .kv 文件中,我有這樣的內容:
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 是一個帶有 CheckBox 和 Label 的 BoxLayout.它有:
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 與我在 Python 代碼中綁定 StackLayout 的 minimum_height 和 height 相同,如果我理解正確的話.
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.
推薦答案
改變
minimum_height: self.height
到
height: self.minimum_height
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).
這篇關于Kivy ScrollView - 不滾動的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!