如何滚动的Android版Google+应用工作的? [英] How does scrolling work in the Google+ Android app?
问题描述
我注意到,在与玩了,如果你和滚动从Google+ Android应用在流了下来,滚动条根据当前可见后的垂直尺寸(S)(S更改大小)。例如,如果您滚动成一个长发帖,酒吧缩小规模,如果您滚动到一个简短的帖子,它延长。这是如何实现的?
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.
推荐答案
这是用回收的副作用的ListView
。随着新的职位滚动来查看,该项目的其余部分是虚拟化 - 基本的Android猜测到列表的其余部分多少空间占用,但它实际上并没有使它们,因此不能肯定。当您在滚动一个大后,它假定列表的其余部分中有大柱子,因此名单是更长的时间。
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.
您可以通过使用<一对 convertView
参数得到相同的功能href=\"http://developer.android.com/reference/android/widget/Adapter.html#getView%28int,%20android.view.View,%20android.view.ViewGroup%29\"相对=nofollow> getView
像这样:
You can get the same functionality by using the convertView
parameter of getView
like so:
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View view = null;
if(convertView == null)
{
view = // set your view here
}
else
{
view = convertView
}
// set all your properties on the view here.
return view;
}
这篇关于如何滚动的Android版Google+应用工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!