smoothScrollToPosition()只滚动中途在安卓ICS? [英] smoothScrollToPosition() only scrolls partway in Android ICS?

查看:408
本文介绍了smoothScrollToPosition()只滚动中途在安卓ICS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在姜饼,我不得不使用smoothScrollToPosition()滚动在几十个项目在同一时间没有问题。经过我的Nexus S升级至冰淇淋三明治,我注意到,不管我把smoothScrollToPosition(),它只会滚动在左右两个方向几百像素,然后停止。

In Gingerbread, I had no issues with using smoothScrollToPosition() to scroll across dozens of items at a time. After my Nexus S was upgraded to Ice Cream Sandwich, I noticed that no matter what I put in smoothScrollToPosition(), it will only scroll about a couple of hundred pixels in either direction, and then stop.

这是一个已知的问题与ICS?我注意到这与Galaxy Nexus的为好。我看了一些其他的问题,并尝试了几种不同的技巧,比如调用关闭到notifyDataSetChanged(),并张贴smoothScrollToPosition()作为延迟可运行的,但不幸的是,它并不想滚动多百个像素左右停止前。 :(

Is this a known issue with ICS? I've noticed this with the Galaxy Nexus as well. I've looked at a few other questions and tried a few different tricks, such as turning off calls to notifyDataSetChanged(), and posting the smoothScrollToPosition() as a delayed runnable, but unfortunately, it doesn't want to scroll more than a hundred pixels or so before stopping. :(

推荐答案

似乎是一个问题,完成动画所需的时间,同样的问题是present与smoothScrollBy(INT距离,INT持续时间),在粗略地看一眼,smoothScrollToPosition()是围绕smoothScrollBy(一个友好的包装),做了很多跑腿的。 smoothScrollBy()又编造一个抛球的手势一样,如果用户做了运动。

Appears to be an issue with the duration required to finish the animation, the same issue is present with smoothScrollBy(int distance, int duration), at cursory glance, smoothScrollToPosition() is a friendly wrapper around smoothScrollBy() that does a lot of the legwork. smoothScrollBy() in turn is faking a "fling gesture", as if a user had made the motion.

smoothScrollBy实际上只是张贴了一扔可运行的继续转贴到自己的时间耗尽。这意味着它仅计算滚动偏移量的基础上所需要的是previously决定到,因此,如果持续时间耗尽前,先要到目标偏移,它在过去的偏移计算停止抵消。 (而不是全部一下子跳跃到目标偏移,这也许是更不和谐,因为它不会被动画的)。

smoothScrollBy really just posts the fling runnable that continues to repost itself till the duration runs out. Meaning that it simply computes the scroll offset required based on the offset it previously decided to move to, hence if duration runs out before it gets to the target offset, it stops at the last offset calculated. (Rather than all of sudden jumping to the target offset, which is perhaps more jarring as it would not be animated).

的困难为Android家伙是确定多少由每次运行移动()调用,以达到所要求的补偿,因为ListView的细胞(儿童)在高度上完全动态的,所以他们不能只是做一个简单的距离计算为不可见儿童的身高是未知的给他们。这是同样的道理Android的滚动条的大小可以作为波动滚动,它必须考虑它有多大,应根据它目前看到的最好的猜测。

The difficulty for the Android guys is determining how much to move by each run() call to reach the required offset because ListView cells (children) are entirely dynamic in height, so they can't just do a simple distance calculation as the non-visible children's height are unknown to them. It is the same reason the Android scrollbar can fluctuate in size as you scroll, it has to take a best guess at how big it should be based on what it is currently seeing.

反正不帮你解决这个问题,但有人会觉得很有趣:)

Anyway that doesn't help you solve it but some one might find it interesting :)

如果你知道,但是你有静态单元格的高度,你可以写你自己的方法来计算距离和时间传递给smoothScrollBy()自己,有时间的静态量移动距离X。如果你不这样做,它必须足够使用发布该解决方案bigstones,这确实是工作,因为1000毫秒的高SCROLL_DURATION的。你可以把ICS版本,并更改​​该属性为好,而不是使用2.2版本,这是不是根本原因。

If you know you have static cell heights however, you can write your own method to calculate the distance and duration to pass to smoothScrollBy() yourself and have a static amount of time to move X distance. If you don't, it will have to suffice to use the solution bigstones posted, which really is working because of the high SCROLL_DURATION of 1000ms. You can take the ICS version and change this attribute as well, rather than using the 2.2 version, which is not the root cause.

您也可以调整这些可运行你自己的自定义算法,应该不会太难调整的事情。

You can also adapt those runnables with your own custom algorithm, it shouldn't be too difficult to tweak things.

这篇关于smoothScrollToPosition()只滚动中途在安卓ICS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆