最近应用内,做了浮窗H5,底部,中部,或者嵌入其他容器内,h5非全屏的状态下,出现了上下滑动会偶先回弹的一个bug
附一个演示视频
半屏webview部分机型回弹bug-CSDN直播
通过打日志发现touch事件是没有问题的,问题在于overScrollBy每次回调回来的参数有问题
而这些参数是通过android.webkit.WebView$PrivateAccess一个内部类回调回来的,具体调用方在webview的具体实现里,到这里基本就确定这是webview的具体实现的bug了
既然找到问题那就对症下药,你返回的数据有问题,那我们就只执行正确的数据就好了
private boolean isTouching = false;//是否用户触发的touch事件
private static final int NONE = 0;
private static final int TYPE_INCREASING = 1;//touch事件的y坐标在增大
private static final int TYPE_DECREASING = 2;//touch事件的y坐标在减小
private int touchYType = NONE;
private float lastTouchY = -1;
private int lastScrollY = -1;
@Override
public boolean onTouchEvent(MotionEvent event) {
if (lastTouchY