【问题标题】:SwipeRefreshLayout in KivyKivy 中的 SwipeRefreshLayout
【发布时间】:2018-06-24 02:14:18
【问题描述】:

我正在使用 Kivy 技术开发一个应用程序,我想展示一个拉动刷新行为。我所做的最多的是滚动视图并控制是否要刷新 scroll_y 坐标,但这具有仅在有滚动时才起作用而在没有滚动时不起作用的缺点。

<TrytonTree>
app: app
container: container
do_scroll_x: False
on_scroll_y: root.init_pull(self.scroll_y)
on_scroll_stop: root.pull(self.scroll_y)
MDList:
    id: container
...
class TrytonTree(ScrollView, TrytonTreeMixin):

def pull(self, scroll_y):
    if scroll_y >= 2:
        self.app.refresh_screen([self.get_model_name()])
        Clock.schedule_once(self.app.disable_spinner, 2)

def init_pull(self, scroll_y):
    if scroll_y >= 2:
        self.app.enable_spinner()

所以我的问题是是否有控制滑动手势的方法,以便我可以调用刷新功能或类似的东西。

谢谢。

【问题讨论】:

    标签: python layout kivy


    【解决方案1】:

    你可以直接在运动事件上​​使用这种东西:

    https://kivy.org/docs/api-kivy.input.motionevent.html

    我认为你可以这样做:

    on_touch_move(self, touch):
        self.refresh()
    

    【讨论】:

    • 这是一个很好的解决方案,唯一的问题是我必须检测带有坐标的滑动移动以及我想的“向上移动”运动,但它可以解决。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-05
    • 2015-09-22
    • 2023-03-11
    • 1970-01-01
    • 2014-09-30
    • 2015-12-21
    相关资源
    最近更新 更多