滚动在 Google+ 中是如何工作的?安卓应用程序?
我注意到,在使用它时,如果您在 Google+ Android 应用程序中的流中上下滚动,滚动条的大小会根据当前可见帖子的垂直大小而变化。例如,如果您滚动到长帖子,则该栏的大小会缩小,如果您滚动到短帖子,则该栏的大小会变长。这是如何实施的?
现在,我并不是特别需要这个功能,但这只是激起了我的好奇心。
I've noticed, while playing around with it, that if you scroll up and down in the stream from the Google+ Android app, the scroll bar changes size depending on the vertical size(s) of the currently visible post(s). For example, if you scroll into a long posting, the bar shrinks in size, and if you scroll into a short post, it lengthens. How is this implemented?
Now, I don't particularly need this feature, but it's just something that has piqued my curiosity.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是使用回收
ListView
的副作用。当新帖子滚动查看时,其余项目将被虚拟化 - 基本上 Android 会猜测列表的其余部分将占用多少空间,但它实际上不会渲染它们,因此无法确定。当您滚动到一个大帖子时,它会假设列表的其余部分也有大帖子,因此列表会更长。您可以使用
getView
像这样:It's a side effect of using a recycling
ListView
. As new posts are scrolled in to view, the rest of the items are virtualized - basically Android guesses as to how much space the rest of the list will take up, but it doesn't actually render them so it can't be sure. As you scroll on to a big post, it assumes the rest of the list has big posts in it and therefore the list is longer.You can get the same functionality by using the
convertView
parameter ofgetView
like so: