有没有类似使用smoothScrollToPosition
控制速度或平滑滚动所需时间的方法?
现在我正在使用下面的代码片段来滚动到pos
int firstVisible = lv.getFirstVisiblePosition();
int lastVisible = lv.getLastVisiblePosition();
if (firstVisible > pos)
lv.smoothScrollToPosition(pos, pos - firstVisible - 2);
if (pos > lastVisible)
lv.smoothScrollToPosition(pos, pos + lastVisible + 3);
从这里我修改为上面的片段如下
int childheight = lv.getChildAt(firstVisible).getHeight();
if (firstVisible > pos)
lv.smoothScrollBy(childheight*pos, 800);
if (pos > lastVisible)
lv.smoothScrollBy(childheight*pos, 1200);
但是,我在
int childheight = lv.getChildAt(firstVisible).getHeight();
编辑
我需要通过用户按下按钮自动滚动到 childView,比如 MENU 按钮。由于执行资源密集型任务来填充列表视图,我没有面临列表滚动缓慢的问题。我想要的只是smoothScrollToPosition
with的功能smoothscrooltoPosition with velocity control