1

Hi i am implementing a gridView and i have trouble making it scroll down 1 row at a time with every scroll event.

my grid has a height of 1 row item (items height is 75dp). i don't want scrolling to be left in a middle of a row.

is there a way i can intercept and modify the scroll distance so that it only returns fixed value ex: +-75dp.

i would appreciate any help or suggestions you can give me. tnx

DArkO
  • 15,880
  • 12
  • 60
  • 88

1 Answers1

2

APIv8 has new function, called smoothScrollBy(int distance, int duration)[1]

i think you should catch all scroll events & implement own method to scroll view. if you want to scroll by 75dp, just convert it to pixels & use function above.

float density = getContext().getResources().getDisplayMetrics().density;
int scrollBy = (int)(density * 75);
smoothScrollBy(scrollBy, 0);

But would be nice to calculate scrollBy from your GridView, instead of using some constant value (like 75dp)

[1]: http://developer.android.com/reference/android/widget/AbsListView.html#smoothScrollBy(int, int)

Attenzione
  • 833
  • 9
  • 12