Search code examples
kivyscrollview

ScrollView in Kivy not working properly, rebounding on each scroll down and finally bouncing back all the way to the top page


ScrollView in Kivy not working properly, rebounding on each scroll down and finally bouncing back all the way to the to the top page. How to make it stable(KivyMD on windows 10)

from kivy.lang import Builder
from kivymd.app import MDApp
from kivymd.uix.label import MDLabel
from kivymd.font_definitions import theme_font_styles


KV = '''
Screen:

    BoxLayout:
        orientation: "vertical"

        MDToolbar:
            title: "MDLabel"

        ScrollView:
            MDList:
                GridLayout:
                    id: box
                    cols:1
                    spacing:100
'''


class Test(MDApp):
    def build(self):
        creen = Builder.load_string(KV)
        # Names of standard font styles.
        for name_style in theme_font_styles[:-1]:
            for i in range(0, 10):
                creen.ids.box.add_widget(
                    MDLabel(
                        size=creen.ids.box.size,
                        text=f"{name_style} style",
                        halign="center",
                        font_style=name_style,
                    )
                )
        return creen


Test().run()

Solution

  • Try adding:

                    size_hint_y: None
                    height: self.minimum_height
    

    to your GridLayout.