Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android listview smothScrollBy的速度?_Android_Android Listview_Android Scroll - Fatal编程技术网

Android listview smothScrollBy的速度?

Android listview smothScrollBy的速度?,android,android-listview,android-scroll,Android,Android Listview,Android Scroll,有没有类似的方法,比如使用smoothScrollToPosition控制速度或平滑滚动所需的时间 现在我正在使用下面的代码片段来搜索pos int firstVisible = lv.getFirstVisiblePosition(); int lastVisible = lv.getLastVisiblePosition(); if (firstVisible > pos) lv.smoothScrollToPosition(po

有没有类似的方法,比如使用
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);
但是,我在

编辑


我需要通过用户按一个按钮(比如菜单按钮)自动搜索儿童视图。我不会因为执行资源密集型任务来填充listview而面临列表滚动缓慢的问题。我想要的只是
smoothScrollToPosition
smoothScrolToposition与速度控制的功能,我建议您使用动画@MiguelAngel_LV,谢谢你的链接,但我认为我应该在用户滚动时应用动画效果;我还需要通过按下按钮自动滚动到子视图,比如说菜单按钮,@nmxprime您在Listview中尝试过android:fastScrollEnabled=“true”属性吗?@DhruvVaishnav,它只显示滚动条,我想要的是列表滚动到指定位置,就像我们拖动滚动条一样。
  int childheight = lv.getChildAt(firstVisible).getHeight();