Scroll a ListView by pixels in Android

后端 未结 5 1431
隐瞒了意图╮
隐瞒了意图╮ 2021-02-06 08:50

I want to scroll the a ListView in Android by number of pixels. For example I want to scroll the list 10 pixels down (so that the first item on the list has its top

5条回答
  •  渐次进展
    2021-02-06 09:35

    if you want to move by pixels then u can use this

    public void scrollBy(ListView l, int px){
        l.setSelectionFromTop(l.getFirstVisiblePosition(),l.getChildAt(0).getTop() - px);
    }
    

    this works for even ones with massive headers

提交回复
热议问题