第一步,重写WebView的onGenericMotionEvent方法
/** * 滑轮处理 */ @Override public boolean onGenericMotionEvent(MotionEvent event) { if (callback != null) return callback.onGenericMotionEvent(event); return super.onGenericMotionEvent(event); } //定义一个接口,把滚动事件传递出去 public interface GenericMotionCallback { boolean onGenericMotionEvent(MotionEvent event); } GenericMotionCallback callback; public void setCallback(GenericMotionCallback callback) { this.callback = callback; }
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
第二步,让对应的WebView对象调用之前setCallback这个方法,返回外部ScrollView的滚轮事件
mExpectIncomeWeb.setCallback(new WZWebView.GenericMotionCallback() { @Override public boolean onGenericMotionEvent(MotionEvent event) { return mScrollView.onGenericMotionEvent(event); } });\