【发布时间】:2019-08-07 14:00:31
【问题描述】:
好的,所以我正在使用 Kivy(1.11.1) 构建一些东西,并总结一下我有一个垂直滚动的 ScrollView,其中还有一些其他 ScrollView,但这些仅水平滚动,问题是每当我滚动外部 ScrollView 向下并且鼠标位置进入内部 Horizontal ScrollViews 外部 Scrollview 停止向下滚动,看起来一旦鼠标位置与水平滚动视图发生冲突,滚动行为就会停止发送到外部 ScrollView(垂直),因此它停止向下滚动.我想要的是类似于 Netflix 页面的东西,其中有一些水平滚动视图(我的列表、系列、恐怖电影等),您可以滚动以查看更多选项,但它们都在垂直滚动的外部滚动视图中,当然,在 Netflix 中,当您向下滚动时,即使您的鼠标位置进入水平滚动视图之一,它仍然会继续向下滚动外部 ScrollView。
我尝试将水平滚动视图 do_scroll_y 设置为 False,但问题仍然存在。除此之外。向上滚动效果很好
from kivy.app import App
from kivy.lang.builder import Builder
from kivy.uix.boxlayout import BoxLayout
Builder.load_string(
'''
<ScrollApp>:
ScrollView:
bar_width: 10
scroll_type: ['bars', 'content']
BoxLayout:
id: content
orientation: 'vertical'
size_hint: 1, None
height: self.minimum_height
padding: 22, 0, 22, 50
spacing: 50
canvas:
Color:
rgba: .15, .15, .15, .9
Rectangle:
size: self.size
pos: self.pos
Button:
size_hint: None, None
width: 100
height: 100
on_press: print('pressed')
# "ScrollViews containers"
Custom
Custom
Custom
Custom
<Custom@BoxLayout>:
orientation: 'vertical'
size_hint: 1, None
height: self.minimum_height
Label:
size_hint: None, None
size: self.texture_size
id: label
font_size: 20
ScrollView:
size_hint: 1, None
height: 150
do_scroll: True, False
on_scroll_start: print('scrolling. but why?')
GridLayout:
id: grid
size_hint: None, None
size: self.minimum_width, 150
spacing: 5
cols: 3
Button:
size_hint: None, None
size: 400, 150
Button:
size_hint: None, None
size: 400, 150
Button:
size_hint: None, None
size: 400, 150
''' )
class ScrollApp(BoxLayout):
pass
class Test(App):
def build(self):
return ScrollApp()
Test().run()
【问题讨论】:
-
如果您发布minimal reproducible example,您更有可能获得一些帮助。
-
好的,谢谢。现在它确实有效
-
如果您找到了答案,您应该将其发布(回答您自己的问题)以供可能遇到这种情况的其他人使用。
-
对不起,我的意思是我发布的代码现在确实像一个最小的可重现示例一样工作。虽然我没有找到问题的答案
标签: python kivy scrollview kivy-language