Android使用ScrollView控件拉动刷新

发布于 2024-12-19 14:43:36 字数 195 浏览 6 评论 0原文

我正在使用 ScrollView 来显示在运行时膨胀的项目列表。就像用户的更新源一样。 在考虑让用户使用新通知更新视图的选项时,我想到了 Twitter 应用程序中的下拉刷新功能。

有人知道如何以及是否可以使用 ScrollView 来实现它吗?

看到有一些使用 ListView 的实现,但我不喜欢改变我的所有平台来获得这种刷新效果的想法。

I am using a ScrollView to display a list of items that are inflated on runtime. Like a feed of updates for the user.
While thinking about the options i got to let the user update the view with new notifications I thought about the pull to refresh feature in the twitter app.

Anyone got any idea how and if can it be implemented with a ScrollView ?

Saw there are some implementations for that using ListView but I don't like the idea of changing all of my platform to gain this refresh effect.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我很OK 2024-12-26 14:43:36

引入了一种解决方案,用于为各种可滚动的组件(如列表视图和滚动视图)实现拉动刷新。
查看 ChangeLog 链接 https://github.com/chrisbanes/Android-PullToRefresh

There is a solution introduced for implementing pull to refresh for various component which are scrollable like listview and scroollview.
Look at ChangeLog link https://github.com/chrisbanes/Android-PullToRefresh

怪我闹别瞎闹 2024-12-26 14:43:36

仅包含一个元素的 ListView 可以被视为 ScrollView。您可以使用下拉刷新 ListView 的实现,并在其中仅添加一项。我过去曾用过这个技巧。

ListView with just one element can be treated as a ScrollView. You can use the implementation for pull-to-refresh ListView and add just one item in it. I had used this trick in the past.

魔法唧唧 2024-12-26 14:43:36

你可以这么做。当用户向下移动手指并且滚动视图位于其顶部时,您可以增加滚动视图的上边距。然后在发布时触发更新并通过动画减少边距。(您必须创建自己的动画才能实现这一点)。就是这个想法。如果您需要更具体的帮助,请询问您无法实施的内容。

You can do that. You can increase the top margin of the scrollview when the user moves the finger down and the scrollview it's on it's top. Then on release fire the update and decrease the margin with animation.(You have to create your own animation to pull that off). That's the idea. If you want more particular help ask what you cannot implement.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文