v4包中的SwipeRefreshLayout包裹webview时,如果webview加载的html页有固定表头和上下滚动的表格,会造成滑动冲突,下滑会一直调用刷新而不是html页的数据滚动,解决方法是重写webview。
public class WebView4Scroll extends WebView{
public WebView4Scroll(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()){
case MotionEvent.ACTION_DOWN:
if(this.getScrollY() <= 0)
this.scrollTo(0,1);
break;
case MotionEvent.ACTION_UP:
// if(this.getScrollY() == 0)
// this.scrollTo(0,-1);
break;
}
return super.onTouchEvent(event);
}
}
很简单的重写,每次按下的时候,如果在0,0坐标,让它滚动到0,1,这样就会告诉SwipeRefreshLayout他还在滑动,就不会触发刷新事件了。