Android的反弹时了滚动 [英] Android overscroll for ScrollView

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

问题描述

<我一个href=\"http://stackoverflow.com/questions/22790547/android-listview-onoverscrolled-and-onoverscroll-never-be-called-on-2-3\">asked前约反弹时ListView中。默认反弹时不工作在许多设备(例:三星Galaxy 2,HTC One X的)。所以我做了 OverScrollListView

I asked before about OverScroll in ListView. Default overScroll doesn't work on many devices (for ex.: Samsung Galaxy 2, HTC One X). So I made OverScrollListView

但是,现在需要为滚动型这样做。我做的伎俩顶级反弹时(通过使用正数 overScrollBy )。但是,当我试图做底是相同的(由 overScrollBy 用负数),反弹时滚动型滚动到顶部位置。

But now needed to do the same for ScrollView. I made the trick for top overscroll (by using positive number in overScrollBy). But when i'm trying to do the same for bottom (by using a negative number in overScrollBy), overscroll ScrollView scrolling to top position.

有人会说为什么?

P.S。我也试过<一个href=\"https://github.com/EverythingMe/OverScrollView/blob/master/src/me/everything/android/widget/OverScrollView.java\"相对=nofollow>这个。但在中间的某个位置显示,即使在顶部(或底部)滚动条位置指示器。
这迷惑用户...

P.S. I also tried this. But even in top (or bottom) position scrollbar indicator shown somewhere in middle. This confuse the user...

推荐答案

好吧,我想我做到了。

但是,这真的很奇怪。

But it's really strange.

我有反弹时的方法,我在ACTION_MOVE拨打:

I had method for overscroll that i call in ACTION_MOVE:

private void pullDown(int deltaY, int lastY) {
    overScrollBy(0, mSlowEffect ? (int)getOverScrollYWithSlow(deltaY) : deltaY, 0, lastY, 5, 5, 0, mMaxYOverscrollDistance, true);
}

有关ListView控件的反弹时我只设置DELTAY像下拉(lastScroll,0);

For ListView for overscroll i just set deltaY something like pullDown(lastScroll, 0);

它的工作原理为:顶部和底部反弹时

It works for both: top and bottom overscroll.

不过了滚动它并不适用于底部反弹时工作。因此,我们应该送这个方法目前也位置scrollY,像下拉(lastScroll,lastY);

But for ScrollView it doesn't work for bottom overscroll. So we should send to this method also current scrollY position, something like pullDown(lastScroll , lastY);

我分享整个code Github上,如果有人有兴趣。

I share whole code on Github, if someone interested.

这篇关于Android的反弹时了滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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