开发者

GridView Scroll By one row

开发者 https://www.devze.com 2023-02-06 17:12 出处:网络
Hi i am implementing a gridView and i have trouble making it scroll down 1 row at a time with every scroll event.

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 t开发者_StackOverflow中文版he scroll distance so that it only returns fixed value ex: +-75dp.

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


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消