GridView控件通过滚动一行 [英] GridView Scroll By one row

查看:359
本文介绍了GridView控件通过滚动一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我是执行一个GridView和我有麻烦使得它向下滚动1行,在每滚动事件的时候。

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

我的网格具有1行项目的高度(项目高度75dp)。我不想滚动,以留在一排的中间。

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.

有没有办法,我可以截获并修改的滚动距离,使其只返回固定值例:+ -75dp

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

我会AP preciate任何帮助或建议,您可以给我。 TNX

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

推荐答案

APIv8有新的功能,称为smoothScrollBy(INT距离,INT持续时间)[1]

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

我想你应该抓住一切滚动事件和放大器;实现自己的方法来滚动视图。 如果你想通过75dp滚动,只需将它转换为像素和放大器;使用以上功能。

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);

但将是很好,从你的GridView来计算,而不是使用一些常量的值(比如75dp)scrollBy,

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)

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

这篇关于GridView控件通过滚动一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆