Android(列表)视图像 Sense UI 一样滚动
我在 google 和 stackoverflow 上搜索了一段时间,但找不到解决方案。 是否有可能像 sense ui 那样在 Android 2.2 或 2.1 上获得 listview 过度滚动? 就像我的闹钟视图中的那样: AlarmView Sense UI
I've searched some time on google and on stackoverflow but i can't find a solution.
Is there any posibility to get a listview overscroll on Android 2.2 or 2.1 like the sense ui does?!
Like here in my alarm view: AlarmView Sense UI
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
看到奇拉格的回答得到如此高的评价,我感到很震惊。它对任何人都没有帮助,因为它不完整并且无法构建。它也没有引用其来源。
原始代码位于:http://code.google.com/p/scroll-pager /
另请注意,滚动分页器代码是在 GPL 许可证下发布的。
更新 :
我与scroll-pager的作者交谈过,他现在已经切换到MIT许可证。
I'm shocked to see Chirag's answer being highly rated like this. It isn't helpful to anyone because its incomplete and doesn't build. It also doesn't cite its source.
The original code is found here: http://code.google.com/p/scroll-pager/
Also note that the scroll-pager code is released under the GPL license.
UPDATE :
I talked to the author of scroll-pager and he has now switched to the MIT license.
Listview 内置了对过度滚动的支持。查看 setOverscrollMode 及相关方法 setOverscrollHeader 和 setOverscrollFooter。 ListView 通过覆盖 AbsListView.onOverscrolled;如果您想要不同的行为,您可以通过自己覆盖它来实现它。
Listview has built-in support for overscrolling. Check out setOverscrollMode and related methods setOverscrollHeader and setOverscrollFooter. ListView makes use of the overscroll header/footer by overriding AbsListView.onOverscrolled; if you want different behavior, you can implement it by overriding it yourself.
http://developer.android.com/reference/android/widget/ScrollView.html
您永远不应该将 ScrollView 与 ListView 一起使用,因为 ListView 负责其自己的垂直滚动。最重要的是,这样做会破坏 ListView 中处理大型列表的所有重要优化,因为它有效地强制 ListView 显示其整个项目列表以填充 ScrollView 提供的无限容器。
http://developer.android.com/reference/android/widget/ScrollView.html
You should never use a ScrollView with a ListView, because ListView takes care of its own vertical scrolling. Most importantly, doing this defeats all of the important optimizations in ListView for dealing with large lists, since it effectively forces the ListView to display its entire list of items to fill up the infinite container supplied by ScrollView.
我可以看到这篇文章已经很老了,但我最近在 GitHub 上发布了这个开源项目 它解决了这个问题,并可以帮助其他人解决未来类似的过度滚动问题。
它基本上为许多核心 Android 可滚动视图提供类似 iOS 的过度滚动效果 - ListView 就是其中之一,并且非常容易应用。
特别是对于列表视图,您只需执行以下操作即可启用它:
并且要将项目包含在您的项目中,请将其添加到您的 build.gradle 中:
I can see this post is pretty old, but I've recently released this open-source project on GitHub which solves this problem and could help others solve similar over-scroll issues in the future.
It basically provides an iOS-like over-scrolling effect for many core Android scrollable views - ListView is one of them, and is very easy to apply.
Specifically for list-views, all you have to do to enable it this:
And to include the project in yours, add this to your build.gradle:
在 xml 文件中定义滚动视图。
然后在你的java文件中写入:
并在上面的java文件中添加一个类:
Define scrollview in your xml file.
Then in your java file wite this:
And Add a class in above java file: