KivyMD MDSwiper动画问题时,使用ScrollView



我试图在ScrollView屏幕内做多个MDSwiper屏幕,但是当滑动事件被触发时MDSwiper的动画(图像大小应该调整大小)不起作用,我不知道为什么。在ScrollView之外,它可以正常工作。

main.py

from kivymd.app import MDApp
from kivy.lang import Builder
from kivymd.uix.screen import MDScreen
from kivymd.uix.boxlayout import MDBoxLayout
class MainScreen(MDScreen):
pass
class MDNavigationLayout(MDBoxLayout):
pass
class ContentNavigationDrawer(MDBoxLayout):
pass
class TestApp(MDApp):
def build(self):
self.title = 'TestApp'
view = Builder.load_file('main.kv')
return view
if __name__ == '__main__':
TestApp().run()

main.kv

<ContentNavigationDrawer>:
orientation: 'vertical'
padding: '8dp'
spacing: '8dp'
MDLabel:
text: 'Title'
font_style: 'Caption'
size_hint_y: None
height: self.texture_size[1]
ScrollView:
MDList:
OneLineIconListItem:
text: 'Item 1'
on_press:
root.nav_drawer.set_state('close')
IconLeftWidget:
icon: 'account'
<SwiperItem1@MDSwiperItem>:
RelativeLayout:
FitImage:
source: 'image.jpg'
radius: [20,]
MDBoxLayout:
adaptive_height: True
spacing: '12dp'
MDLabel:
text: 'Image1'
font_style: 'H5'
size_hint_y: None
height: self.texture_size[1]
pos_hint: {'center_y': .5}
opposite_colors: True
MDNavigationLayout:
scrm: scrm
ScreenManager:
id: scrm
main_screen: main_screen
MainScreen:
scrm: scrm
nav_drawer: nav_drawer
id: main_screen
MDNavigationDrawer:
id: nav_drawer
md_bg_color: 1, 1, 1, .4
ContentNavigationDrawer:
scrm: scrm
nav_drawer: nav_drawer
<MainScreen>:
MDBoxLayout:
orientation: 'vertical'
size_hint: 1, 1
ScrollView:
MDList:
size_hint_y: .8
padding: '10dp'
spacing: '10dp'
MDSwiper:
id: swiper_1
size_hint_y: None
height: 260
SwiperItem1:
SwiperItem1:
SwiperItem1:
MDSwiper:
id: swiper_2
size_hint_y: None
height: 260
SwiperItem1:
SwiperItem1:
SwiperItem1:
MDSwiper:
id: swiper_3
size_hint_y: None
height: 260
SwiperItem1:
SwiperItem1:
SwiperItem1:

我需要一些建议(可能是一个kivymd bug, idk),谢谢!

您不应该在ScrollView小部件中放置可滚动的小部件。基维有虫子。无法在垂直ScrollView中滚动水平内容。

相关内容

  • 没有找到相关文章

最新更新