Android 解决WebView和ScrollView滚轮滑动
作者:
Greathfs | 来源:发表于
2017-05-07 16:37 被阅读138次
第一步,重写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;
}
第二步,让对应的WebView对象调用之前setCallback这个方法,返回外部ScrollView的滚轮事件
mExpectIncomeWeb.setCallback(new WZWebView.GenericMotionCallback() {
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
return mScrollView.onGenericMotionEvent(event);
}
});
本文标题:Android 解决WebView和ScrollView滚轮滑动
本文链接:https://www.haomeiwen.com/subject/vjoutxtx.html
网友评论