1

Is there any way similar like using smoothScrollToPosition with control over speed or the time it takes to scroll smoothly?

Now i am using below snippet to scrool to 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);
    

From this i modified to aabove snippet as below

    int childheight = lv.getChildAt(firstVisible).getHeight();

            if (firstVisible > pos)
                lv.smoothScrollBy(childheight*pos, 800);
            if (pos > lastVisible)
                lv.smoothScrollBy(childheight*pos, 1200);

But, i get nullpointer exceptions at

  int childheight = lv.getChildAt(firstVisible).getHeight();

Edit

i am in need of scrooling automatically to a childView by a button press by user,say MENU button. I am not facing the problem of list scrolling slowly because of doing resource intensive task to populate listview. All i want is the functionality of smoothScrollToPosition with smoothscrooltoPosition with velocity control

Community
  • 1
  • 1
nmxprime
  • 1,506
  • 3
  • 25
  • 52
  • I guest that you should use a Animation. http://stackoverflow.com/questions/21588188/listview-item-scroll-animation-uikit-dynamics-like – MiguelAngel_LV Jun 27 '14 at 09:44
  • @MiguelAngel_LV, Thanks for the link, but i think i should apply animation effect would when user scrolls; i m also in need of scrooling automatically to a childView by a button press,say MENU button, – nmxprime Jun 27 '14 at 09:49
  • @nmxprime Have you try android:fastScrollEnabled="true" property in Listview? – Dhruv Jun 27 '14 at 09:52
  • @DhruvVaishnav, it just shows scrollbar, what i want is the list to scroll to the specified position as like we drag the scroll bar. – nmxprime Jun 27 '14 at 10:02

0 Answers0