Android使用ScrollView控件拉动刷新
我正在使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
引入了一种解决方案,用于为各种可滚动的组件(如列表视图和滚动视图)实现拉动刷新。
查看 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
仅包含一个元素的
ListView
可以被视为ScrollView
。您可以使用下拉刷新ListView
的实现,并在其中仅添加一项。我过去曾用过这个技巧。ListView
with just one element can be treated as aScrollView
. You can use the implementation for pull-to-refreshListView
and add just one item in it. I had used this trick in the past.你可以这么做。当用户向下移动手指并且滚动视图位于其顶部时,您可以增加滚动视图的上边距。然后在发布时触发更新并通过动画减少边距。(您必须创建自己的动画才能实现这一点)。就是这个想法。如果您需要更具体的帮助,请询问您无法实施的内容。
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.