android - Kivy infinite scroll -


i want create infinite scroll app. it's code:

from kivy.app import app kivy.uix.scrollview import scrollview kivy.uix.gridlayout import gridlayout kivy.uix.image import asyncimage   images_urls = ['https://upload.wikimedia.org/wikipedia/commons/c/c3/jordan_by_lipofsky_16577.jpg' _ in range(5)]   def upload_images(widget):     layout = widget.children[0]     layout_childrens = len(layout.children)     url in images_urls:         img = asyncimage(source=url, size_hint_y=none, height=240)         layout.add_widget(img)     widget.scroll_y = 100 - (100 * layout_childrens / (layout_childrens + len(images_urls)))   class infinityscrollview(scrollview):     def on_scroll_move(self, touch):         if self.scroll_y < 0:             upload_images(self)         return super(infinityscrollview, self).on_scroll_move(touch)   class infinitescrollapp(app):     def build(self):         layout = gridlayout(cols=1, spacing=10, size_hint_y=none)         layout.bind(minimum_height=layout.setter('height'))         url in images_urls:             img = asyncimage(source=url, size_hint_y=none,                              height=240)             layout.add_widget(img)         root = infinityscrollview(size_hint=(none, none), size=(400, 400),                                   pos_hint={'center_x': .5, 'center_y': .5})         root.add_widget(layout)         return root   if __name__ == '__main__':     infinitescrollapp().run() 

i overrode on_scroll_move method , when scroll on bottom called upload_images method adds new images.

it's work fine got problem scroll position stay on bottom after image loading, wont move first loaded images.

i tried set correct value scroll_y doesn't work, maybe must call method or change other variables. advices?

i found solution, needed override 2 variables (scroll_y , effect_y). it's issue on github found solution. it's fixed code.

def upload_images(self):     layout = self.children[0]     layout_childrens = len(layout.children)     url in images_urls:         img = asyncimage(source=url, size_hint_y=none, height=240)         layout.add_widget(img)     bar_position = layout_childrens / (layout_childrens + len(images_urls))     self.scroll_y = 100 - 100 * bar_position     self.effect_y.value = self.effect_y.min - self.effect_y.min * bar_position 

Comments