且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

GridView控件通过滚动一行

更新时间:2023-08-28 22:42:04

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)