开发者

How can I scroll ListView continually with a constant velocity from code?

I have a ListView in which the user can drag&drop list elements to reorder the list (android 3.0). However, I have to handle the case when the list is long, and the user has to be able to scroll it during dragging an item. So I've put two scroll-areas onto the screen, one at the top and one at the bottom. When the user drags an item onto these, the Li开发者_StackOverflowstView should start to scroll up/down with a constants speed, as long as the dragged item is in these areas.

How can I achieve this scrolling with ListView?

I've tried the smoothScroll...() methods but they need a specific position in the list to scroll to, or a specific distance to scroll by. The standard scrollBy...() methods don't work either, they scroll the ListView, but don't appear to invalidate is properly, so the appearing rows don't get rendered.

Any ideas?


You could try listView1.smoothScrollByOffset(int viewPosition). This way you could make the listview scroll up and down by an interval of 1+ views.


You could try smoothScrollToPositionFromTop(int position, int offset, int duration) with varying duration depending on the position where to scroll, like say

int duration = position*100;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜